def confirm_email(self, token): try: email = self._confirm_link_generator.loads(token, salt=HomeView.SALT_LINK, max_age=HomeView.CONFIRM_LINK_TTL) confirm_user = ProviderUser.objects(email=email).first() if confirm_user: confirm_user.status = ProviderUser.Status.ACTIVE confirm_user.save() login_user_wrap(confirm_user) return redirect(url_for('HomeView:signin')) else: return '<h1>We can\'t find user.</h1>' except SignatureExpired: return '<h1>The token is expired!</h1>'
def post_login(form: SigninForm): if not form.validate_on_submit(): flash_error(form.errors) return render_template('home/login.html', form=form) check_user = ProviderUser.objects(email=form.email.data).first() if not check_user: flash_error(gettext(u'User not found.')) return render_template('home/login.html', form=form) if check_user.status == ProviderUser.Status.NO_ACTIVE: flash_error(gettext(u'User not active.')) return render_template('home/login.html', form=form) if not ProviderUser.check_password_hash(check_user['password'], form.password.data): flash_error(gettext(u'Invalid password.')) return render_template('home/login.html', form=form) login_user_wrap(check_user) return redirect(url_for('ProviderView:dashboard'))