diff --git a/app_api/views.py b/app_api/views.py index e18b580..67f0736 100644 --- a/app_api/views.py +++ b/app_api/views.py @@ -38,19 +38,19 @@ def oauth0(request): # 1 、验证timestamp的时效性 nowtime = int (time.time()) # 时间戳失效时间,默认为3600,可以改短,如30,严格点5秒,如果使用5秒,请求前,需要通过get_timestamp获取服务器时间戳,否则因为和服务器时间差导致无法验证通过 - if (nowtime - int(timestamp)) > 3600 : - return JsonResponse({'status':False,'data':nowtime,'errormsg':"out of time"}) + if (nowtime - int(timestamp)) > 3600 : + raise ValueError('链接已失效,请从合法路径访问,或联系管理员!') # 2、获取userid的Token user = User.objects.get(username=username) if user is None: - return JsonResponse({'status':False,'data':nowtime,'errormsg':'user error!'}) + raise ValueError('请求用户出错!') 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: - return JsonResponse({'status':False,'data':nowtime,'errormsg':'user deny!'}) + raise ValueError('非法用户!') # 3、 验证hash的正确性 final_str = str(randstr) + str(timestamp) + str(username) + token @@ -61,12 +61,16 @@ def oauth0(request): from urllib.parse import unquote newurl = unquote(redirecturl) return redirect(newurl) - else: - return JsonResponse({'status':False,'data':nowtime,'errmsg':'hash error!'}) + else: + raise ValueError('验证失败,可能是用户名或Token不正确!详情请联系管理员!') else: - return JsonResponse({'status':False,'data':'Some keywords is empty!'}) + raise ValueError('关键字验证失败,请联系管理员!部分关键字为空') + except ValueError as e: + errormsg = e + return render(request, 'app_api/api404.html', locals()) except : - return JsonResponse({'status':False,'data':'Something wrong here!!'}) + errormsg = "API接口运行出错!" + return render(request, 'app_api/api404.html', locals()) else: return JsonResponse({'status':False,'data':'Nothing Here'}) diff --git a/template/app_api/api404.html b/template/app_api/api404.html new file mode 100644 index 0000000..6848696 --- /dev/null +++ b/template/app_api/api404.html @@ -0,0 +1,26 @@ +{% load static %} +{% load i18n %} + + + + + {% trans "页面未找到" %} - {% if site_name != None %}{{site_name}} {% else %}{% trans "觅道文档MrDoc" %}{% endif %} + + + + + + +{% include 'app_doc/head_base.html' %} + +
+
+


{{errormsg }}




+

{% trans "返回首页" %}

+
+
+ + + + + \ No newline at end of file diff --git a/template/app_doc/manage/manage_project_options.html b/template/app_doc/manage/manage_project_options.html index 489404e..17e80eb 100644 --- a/template/app_doc/manage/manage_project_options.html +++ b/template/app_doc/manage/manage_project_options.html @@ -247,6 +247,7 @@ 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){ diff --git a/template/app_doc/pro_list.html b/template/app_doc/pro_list.html index ea48564..dc01a28 100644 --- a/template/app_doc/pro_list.html +++ b/template/app_doc/pro_list.html @@ -301,6 +301,7 @@ console.log(selected_icon) $("#project-icon-select").html(selected_icon_svg) $("#picon").val(selected_icon) + $("#project-icon-select-box").toggleClass("hide-project-icon-list") })