diff --git a/oj/urls.py b/oj/urls.py index 7bba7f75..d2beba16 100644 --- a/oj/urls.py +++ b/oj/urls.py @@ -5,7 +5,7 @@ from django.views.generic import TemplateView from account.views import (UserLoginAPIView, UsernameCheckAPIView, UserRegisterAPIView, UserChangePasswordAPIView, EmailCheckAPIView, - UserAdminAPIView, UserInfoAPIView, + UserAdminAPIView, UserInfoAPIView, ResetPasswordAPIView, ApplyResetPasswordAPIView, SSOAPIView, UserProfileAPIView) from announcement.views import AnnouncementAdminAPIView @@ -122,13 +122,14 @@ urlpatterns = [ url(r'^user/(?P.+)/$', "account.views.user_index_page"), - url(r'^api/reset_password/$', ApplyResetPasswordAPIView.as_view(), name="apply_reset_password_api"), - + url(r'^api/apply_reset_password/$', ApplyResetPasswordAPIView.as_view(), name="apply_reset_password_api"), + url(r'^api/reset_password/$', ResetPasswordAPIView.as_view(), name="apply_reset_password_api"), url(r'^account/settings/$', TemplateView.as_view(template_name="oj/account/settings.html"), name="account_setting_page"), url(r'^account/settings/avatar/$', TemplateView.as_view(template_name="oj/account/avatar.html"), name="avatar_settings_page"), url(r'^account/sso/$', SSOAPIView.as_view(), name="sso_api"), url(r'^api/account/userprofile/$', UserProfileAPIView.as_view(), name="userprofile_api"), - url(r'^reset_password/$', TemplateView.as_view(template_name="oj/account/reset_password.html"), name="reset_password_page") + url(r'^reset_password/$', TemplateView.as_view(template_name="oj/account/apply_reset_password.html"), name="apply_reset_password_page"), + url(r'^reset_password/t/(?P\w+)/$', "account.views.reset_password_page", name="reset_password_page") ] diff --git a/static/src/js/app/oj/account/applyResetPassword.js b/static/src/js/app/oj/account/applyResetPassword.js new file mode 100644 index 00000000..17b890b2 --- /dev/null +++ b/static/src/js/app/oj/account/applyResetPassword.js @@ -0,0 +1,39 @@ +require(["jquery", "bsAlert", "csrfToken", "validator"], function ($, bsAlert, csrfTokenHeader) { + var applied_captcha = false; + $('form').validator().on('submit', function (e) { + if (!e.isDefaultPrevented()) { + var email = $("#email").val(); + var captcha = $("#captcha").val(); + + $.ajax({ + beforeSend: csrfTokenHeader, + url: "/api/reset_password/", + data: {email: email, captcha: captcha}, + dataType: "json", + method: "post", + success: function (data) { + if (!data.code) { + refresh_captcha(); + bsAlert(data.data); + } + else { + refresh_captcha(); + bsAlert(data.data); + } + }, + error: function(){ + bsAlert("额 好像出错了,请刷新页面重试。如还有问题,请填写页面导航栏上的反馈。") + } + + }); + return false; + } + }); + function refresh_captcha(){ + $("#captcha-img")[0].src = "/captcha/?" + Math.random(); + $("#captcha")[0].value = ""; + } + $("#captcha-img").click(function(){ + refresh_captcha(); + }); +}); \ No newline at end of file diff --git a/template/src/oj/account/apply_reset_password.html b/template/src/oj/account/apply_reset_password.html new file mode 100644 index 00000000..5b5dc709 --- /dev/null +++ b/template/src/oj/account/apply_reset_password.html @@ -0,0 +1,40 @@ +{% extends "oj_base.html" %} +{% block title %} + 找回登录信息 +{% endblock %} +{% block body %} +
+
+

找回登录信息


+
+

请输入你注册时使用的邮箱地址,系统将自动向你的邮箱发送一封含有您登录信息的电子邮件, + 你可以看到你的用户名,并可以选择重新设置登录密码,注意为了你的账户安全,重置密码链接仅在30分钟内有效

+
+
+
+
+ + + +
+
+
+    +

+ + +
+
+
+ +
+
+
+
+{% endblock %} +{% block js_block %} + +{% endblock %} \ No newline at end of file