def confirm_register(token): user = User.verify_token(token) if not user: flash('Ошибка. Обратитесь к администратору.') return redirect(url_for('main.index')) user.limit_access = False db.session.commit() if not current_user.is_authenticated: login_user(user) flash('Регистрация подтверждена.') return redirect(url_for('main.index'))
def reset_password2(token): if current_user.is_authenticated: return redirect(url_for('main.index')) user = User.verify_token(token) if not user: flash('Ошибка. Обратитесь к администратору.') return redirect(url_for('main.index')) form = ResetPasswordForm() if form.validate_on_submit(): user.set_password(form.password.data) db.session.commit() flash('Пароль успешно изменен.') return redirect(url_for('user.login')) return render_template('user/reset_password.html', form=form)