Skip to content

Commit fa2df85

Browse files
authored
Merge pull request #502 from laozijiaojiangnan/fix-checkbox
fix(account):修复登录页 checkbox 选中无效的问题
2 parents 3559ec9 + 17b8048 commit fa2df85

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

accounts/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class LoginView(FormView):
8989
template_name = 'account/login.html'
9090
success_url = '/'
9191
redirect_field_name = REDIRECT_FIELD_NAME
92+
login_ttl = 2626560 # 一个月的时间
9293

9394
@method_decorator(sensitive_post_parameters('password'))
9495
@method_decorator(csrf_protect)
@@ -115,6 +116,8 @@ def form_valid(self, form):
115116
logger.info(self.redirect_field_name)
116117

117118
auth.login(self.request, form.get_user())
119+
if self.request.POST.get("remember"):
120+
self.request.session.set_expiry(self.login_ttl)
118121
return super(LoginView, self).form_valid(form)
119122
# return HttpResponseRedirect('/')
120123
else:
221 Bytes
Loading

templates/account/login.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ <h2 class="form-signin-heading text-center">Sign in with your Account</h2>
2525
<div class="checkbox">
2626
{% comment %}<a class="pull-right">Need help?</a>{% endcomment %}
2727
<label>
28-
<input type="checkbox" value="remember-me"> Stay signed in
28+
<input type="checkbox" value="remember-me" name="remember"> Stay signed in
2929
</label>
3030
</div>
3131
{% load oauth_tags %}

0 commit comments

Comments
 (0)