for pass ci...

This commit is contained in:
Chiaki 2017-04-18 12:05:07 +08:00
parent e3692c2329
commit a9b25b872a
4 changed files with 4 additions and 7 deletions

View File

@ -49,4 +49,3 @@ class EditUserSerializer(serializers.Serializer):
class ApplyResetPasswordSerializer(serializers.Serializer): class ApplyResetPasswordSerializer(serializers.Serializer):
email = serializers.EmailField() email = serializers.EmailField()
captcha = serializers.CharField(max_length=4, min_length=4) captcha = serializers.CharField(max_length=4, min_length=4)

View File

@ -11,5 +11,5 @@ urlpatterns = [
url(r"^register$", UserRegisterAPI.as_view(), name="user_register_api"), url(r"^register$", UserRegisterAPI.as_view(), name="user_register_api"),
url(r"^change_password$", UserChangePasswordAPI.as_view(), name="user_change_password_api"), url(r"^change_password$", UserChangePasswordAPI.as_view(), name="user_change_password_api"),
url(r"^apply_reset_password$", ApplyResetPasswordAPI.as_view(), name="apply_reset_password_api"), url(r"^apply_reset_password$", ApplyResetPasswordAPI.as_view(), name="apply_reset_password_api"),
url(r'^reset_password$', ResetPasswordAPI.as_view(), name="apply_reset_password_api") url(r"^reset_password$", ResetPasswordAPI.as_view(), name="apply_reset_password_api")
] ]

View File

@ -3,9 +3,9 @@
from django.conf.urls import url from django.conf.urls import url
from ..views.user import UserInfoAPI ,UserProfileAPI from ..views.user import UserInfoAPI, UserProfileAPI
urlpatterns = [ urlpatterns = [
url(r"^user", UserInfoAPI.as_view(), name="user_info_api"), url(r"^user", UserInfoAPI.as_view(), name="user_info_api"),
url(r"^profile$", UserProfileAPI.as_view(), name="user_profile_api"), url(r"^profile$", UserProfileAPI.as_view(), name="user_profile_api")
] ]

View File

@ -1,11 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import codecs
from datetime import timedelta from datetime import timedelta
from django.contrib import auth from django.contrib import auth
from django.conf import settings
from django.core.exceptions import MultipleObjectsReturned from django.core.exceptions import MultipleObjectsReturned
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.utils.timezone import now from django.utils.timezone import now
@ -116,7 +114,7 @@ class ApplyResetPasswordAPI(APIView):
except User.DoesNotExist: except User.DoesNotExist:
return self.error(_("User does not exist")) return self.error(_("User does not exist"))
if user.reset_password_token_expire_time and 0 < ( if user.reset_password_token_expire_time and 0 < (
user.reset_password_token_expire_time - now()).total_seconds() < 20 * 60: user.reset_password_token_expire_time - now()).total_seconds() < 20 * 60:
return self.error(_("You can only reset password once per 20 minutes")) return self.error(_("You can only reset password once per 20 minutes"))
user.reset_password_token = rand_str() user.reset_password_token = rand_str()