Skip to content

Commit

Permalink
[FIX] auth_totp: Website compatibility
Browse files Browse the repository at this point in the history
* Add website compatibility by modifying the decorator on one of the routes and
updating the login_success request parameter as needed
  • Loading branch information
obulkin committed Jul 13, 2017
1 parent a7547f8 commit ca43743
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion auth_totp/controllers/main.py
Expand Up @@ -55,6 +55,7 @@ def web_login(self, *args, **kwargs):

user.generate_mfa_login_token()
request.session.logout(keep_db=True)
request.params['login_success'] = False
return http.local_redirect(
'/auth_totp/login',
query={
Expand All @@ -64,7 +65,13 @@ def web_login(self, *args, **kwargs):
keep_hash=True,
)

@http.route('/auth_totp/login', type='http', auth='none', methods=['GET'])
@http.route(
'/auth_totp/login',
type='http',
auth='public',
methods=['GET'],
website=True,
)
def mfa_login_get(self, *args, **kwargs):
return request.render('auth_totp.mfa_login', qcontext=request.params)

Expand Down Expand Up @@ -127,6 +134,7 @@ def mfa_login_post(self, *args, **kwargs):
temp_user.generate_mfa_login_token(60 * 24 * 30)
token = temp_user.mfa_login_token
request.session.authenticate(request.db, user.login, token, user.id)
request.params['login_success'] = True

redirect = request.params.get('redirect')
if not redirect:
Expand Down

0 comments on commit ca43743

Please sign in to comment.