Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
孙永强 committed Aug 16, 2024
1 parent 9f662cb commit faf2cae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 1 addition & 3 deletions seahub/api2/endpoints/user.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright (c) 2012-2016 Seafile Ltd.
import logging
from datetime import datetime

from rest_framework import status
from rest_framework.authentication import SessionAuthentication
Expand Down Expand Up @@ -254,8 +253,7 @@ def post(self, request):
send_to = email2contact_email(request.user.username)
site_name = get_site_name()
c = {
'email': send_to,
'time': datetime.now().strftime('%Y-%m-%d %H:%M:%S')
'email': send_to
}
try:
send_html_email(_("Successfully Changed Password on %s") % site_name,
Expand Down
3 changes: 3 additions & 0 deletions seahub/auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def _handle_login_form_valid(request, user, redirect_to, remember_me):

# password is valid, log user in
request.session['remember_me'] = remember_me

return log_user_in(request, user, redirect_to)

@csrf_protect
Expand All @@ -132,6 +133,7 @@ def login(request, template_name='registration/login.html',
remember_me = True if request.POST.get('remember_me',
'') == 'on' else False
redirect_to = request.POST.get(redirect_field_name, '') or redirect_to

# check the form
used_captcha_already = False
if bool(config.FREEZE_USER_ON_LOGIN_FAILED) is True:
Expand All @@ -142,6 +144,7 @@ def login(request, template_name='registration/login.html',
used_captcha_already = True
else:
form = authentication_form(data=request.POST)

if form.is_valid():
return _handle_login_form_valid(request, form.get_user(),
redirect_to, remember_me)
Expand Down

0 comments on commit faf2cae

Please sign in to comment.