You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
967 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 LasLabs Inc.
  3. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)
  4. from openerp.http import redirect_with_hash, request, route
  5. from openerp.addons.auth_totp.controllers.main import AuthTotp
  6. class AuthTotpPasswordSecurity(AuthTotp):
  7. @route()
  8. def mfa_login_post(self, *args, **kwargs):
  9. """Overload to check password expiration after MFA login"""
  10. super_object = super(AuthTotpPasswordSecurity, self)
  11. response = super_object.mfa_login_post(*args, **kwargs)
  12. if not request.params.get('login_success'):
  13. return response
  14. user = request.env['res.users'].sudo().browse(request.uid)
  15. if user._password_has_expired():
  16. user.action_expire_password()
  17. request.session.logout(keep_db=True)
  18. request.params['login_success'] = False
  19. return redirect_with_hash(user.partner_id.signup_url)
  20. return response