1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-20 02:48:51 +00:00

Clear token when change user password

This commit is contained in:
zhengxie
2015-04-29 10:24:29 +08:00
parent 16ec8ed587
commit 3edf280898
2 changed files with 3 additions and 1 deletions

View File

@@ -7,7 +7,7 @@ from seahub.base.accounts import User
from seahub.auth import authenticate from seahub.auth import authenticate
from seahub.auth.tokens import default_token_generator from seahub.auth.tokens import default_token_generator
from seahub.utils import IS_EMAIL_CONFIGURED, send_html_email, \ from seahub.utils import IS_EMAIL_CONFIGURED, send_html_email, \
is_valid_username, is_ldap_user, is_user_password_strong is_valid_username, is_ldap_user, is_user_password_strong, clear_token
from captcha.fields import CaptchaField from captcha.fields import CaptchaField
@@ -156,6 +156,7 @@ class SetPasswordForm(forms.Form):
self.user.set_password(self.cleaned_data['new_password1']) self.user.set_password(self.cleaned_data['new_password1'])
if commit: if commit:
self.user.save() self.user.save()
clear_token(self.user.username)
return self.user return self.user
class PasswordChangeForm(SetPasswordForm): class PasswordChangeForm(SetPasswordForm):

View File

@@ -829,6 +829,7 @@ def user_reset(request, user_id):
new_password = INIT_PASSWD new_password = INIT_PASSWD
user.set_password(new_password) user.set_password(new_password)
user.save() user.save()
clear_token(user.username)
if IS_EMAIL_CONFIGURED: if IS_EMAIL_CONFIGURED:
if SEND_EMAIL_ON_RESETTING_USER_PASSWD: if SEND_EMAIL_ON_RESETTING_USER_PASSWD: