forked from mirror/MrDoc
Revert "修改API接口报错方式、图标选择后关闭"
This reverts commit 9599ff5366fe76a74223d997bb72767e44853ba7.
This commit is contained in:
parent
9599ff5366
commit
3d728518e4
@ -38,19 +38,19 @@ def oauth0(request):
|
||||
# 1 、验证timestamp的时效性
|
||||
nowtime = int (time.time())
|
||||
# 时间戳失效时间,默认为3600,可以改短,如30,严格点5秒,如果使用5秒,请求前,需要通过get_timestamp获取服务器时间戳,否则因为和服务器时间差导致无法验证通过
|
||||
if (nowtime - int(timestamp)) > 3600 :
|
||||
raise ValueError('链接已失效,请从合法路径访问,或联系管理员!')
|
||||
if (nowtime - int(timestamp)) > 3600 :
|
||||
return JsonResponse({'status':False,'data':nowtime,'errormsg':"out of time"})
|
||||
# 2、获取userid的Token
|
||||
user = User.objects.get(username=username)
|
||||
if user is None:
|
||||
raise ValueError('请求用户出错!')
|
||||
return JsonResponse({'status':False,'data':nowtime,'errormsg':'user error!'})
|
||||
ID = user.id
|
||||
State = user.is_active
|
||||
if State == 1 and ID is not None:
|
||||
usertoken = UserToken.objects.get(user_id=ID)
|
||||
token = usertoken.token
|
||||
else:
|
||||
raise ValueError('非法用户!')
|
||||
return JsonResponse({'status':False,'data':nowtime,'errormsg':'user deny!'})
|
||||
|
||||
# 3、 验证hash的正确性
|
||||
final_str = str(randstr) + str(timestamp) + str(username) + token
|
||||
@ -61,16 +61,12 @@ def oauth0(request):
|
||||
from urllib.parse import unquote
|
||||
newurl = unquote(redirecturl)
|
||||
return redirect(newurl)
|
||||
else:
|
||||
raise ValueError('验证失败,可能是用户名或Token不正确!详情请联系管理员!')
|
||||
else:
|
||||
return JsonResponse({'status':False,'data':nowtime,'errmsg':'hash error!'})
|
||||
else:
|
||||
raise ValueError('关键字验证失败,请联系管理员!部分关键字为空')
|
||||
except ValueError as e:
|
||||
errormsg = e
|
||||
return render(request, 'app_api/api404.html', locals())
|
||||
return JsonResponse({'status':False,'data':'Some keywords is empty!'})
|
||||
except :
|
||||
errormsg = "API接口运行出错!"
|
||||
return render(request, 'app_api/api404.html', locals())
|
||||
return JsonResponse({'status':False,'data':'Something wrong here!!'})
|
||||
else:
|
||||
return JsonResponse({'status':False,'data':'Nothing Here'})
|
||||
|
||||
|
@ -1,26 +0,0 @@
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{% trans "页面未找到" %} - {% if site_name != None %}{{site_name}} {% else %}{% trans "觅道文档MrDoc" %}{% endif %}</title>
|
||||
<link href="{% static 'layui/css/layui.css' %}" rel="stylesheet">
|
||||
<link href="{% static 'mrdoc/mrdoc.css' %}" rel="stylesheet">
|
||||
<link rel="icon" href="{% static 'search/mrdoc_logo_300.png' %}" sizes="192x192" />
|
||||
</head>
|
||||
<body class="layui-container">
|
||||
<!-- 页头 -->
|
||||
{% include 'app_doc/head_base.html' %}
|
||||
<!-- 页头结束 -->
|
||||
<div class="layui-main">
|
||||
<div style="text-align: center;">
|
||||
<hr> <br><br><h2>{{errormsg }}</h2> <br><br><hr>
|
||||
<p><a href="{% url 'pro_list' %}" >{% trans "返回首页" %}</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
|
||||
<script src="{% static 'layui/layui.all.js' %}"></script>
|
||||
</body>
|
||||
</html>
|
@ -247,7 +247,6 @@
|
||||
console.log(selected_icon)
|
||||
$("#project-icon-select").html(selected_icon_svg)
|
||||
$("#picon").val(selected_icon)
|
||||
$("#project-icon-select-box").toggleClass("hide-project-icon-list")
|
||||
})
|
||||
//修改文集基础信息
|
||||
modifyProject = function(pro_id,pro_name,pro_intro){
|
||||
|
@ -301,7 +301,6 @@
|
||||
console.log(selected_icon)
|
||||
$("#project-icon-select").html(selected_icon_svg)
|
||||
$("#picon").val(selected_icon)
|
||||
$("#project-icon-select-box").toggleClass("hide-project-icon-list")
|
||||
})
|
||||
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user