comparison MoinMoin/apps/frontend/views.py @ 2933:08007ac96dda

Issue #483 and #482
author Aabhas Majumdar <majumdaraabhas@gmail.com>
date Mon, 23 Feb 2015 00:03:32 +0530
parents 7de85ecc3669
children e2b5a79a1e06
comparison
equal deleted inserted replaced
2901:ac10a2e3eaf6 2933:08007ac96dda
1575 # multistage return 1575 # multistage return
1576 if flaskg._login_multistage_name == 'openid': 1576 if flaskg._login_multistage_name == 'openid':
1577 return Response(flaskg._login_multistage, mimetype='text/html') 1577 return Response(flaskg._login_multistage, mimetype='text/html')
1578 1578
1579 if request.method in ['GET', 'HEAD']: 1579 if request.method in ['GET', 'HEAD']:
1580 # we already have a logged-in user
1581 if flaskg.user.valid:
1582 flash(_("You are already logged in."), "info")
1583 return redirect(url_for('.show_root'))
1580 form = LoginForm.from_defaults() 1584 form = LoginForm.from_defaults()
1581 for authmethod in app.cfg.auth: 1585 for authmethod in app.cfg.auth:
1582 hint = authmethod.login_hint() 1586 hint = authmethod.login_hint()
1583 if hint: 1587 if hint:
1584 flash(hint, "info") 1588 flash(hint, "info")
1585 elif request.method == 'POST': 1589 elif request.method == 'POST':
1586 form = LoginForm.from_flat(request.form) 1590 form = LoginForm.from_flat(request.form)
1587 if form.validate(): 1591 if form.validate():
1588 # we have a logged-in, valid user 1592 # we have a logged-in, valid user
1589 return redirect(url_for('.show_root')) 1593 next_url = request.args.get('next', default=url_for('.show_root'))
1594 return redirect(next_url)
1590 # flash the error messages (if any) 1595 # flash the error messages (if any)
1591 for msg in flaskg._login_messages: 1596 for msg in flaskg._login_messages:
1592 flash(msg, "error") 1597 flash(msg, "error")
1593 return render_template('login.html', 1598 return render_template('login.html',
1594 title_name=title_name, 1599 title_name=title_name,
1599 1604
1600 @frontend.route('/+logout') 1605 @frontend.route('/+logout')
1601 def logout(): 1606 def logout():
1602 flash(_("You are now logged out."), "info") 1607 flash(_("You are now logged out."), "info")
1603 flaskg.user.logout_session() 1608 flaskg.user.logout_session()
1604 return redirect(url_for('.show_root')) 1609 next_url = request.args.get('next', default=url_for('.show_root'))
1610 return redirect(next_url)
1605 1611
1606 1612
1607 class ValidChangePass(Validator): 1613 class ValidChangePass(Validator):
1608 """Validator for a valid password change 1614 """Validator for a valid password change
1609 """ 1615 """