def login(): try: check_form_para(['email', 'password']) except AssertionError: flash(u'请输入邮箱和密码') return redirect(url_for('home.intro', login_error=1)) user_to_login = UserHelper.get_by_email(request.form['email']) if user_to_login == None or not UserHelper.verify_password(user_to_login, request.form['password']): flash(u'无效的邮箱或密码') return redirect(url_for('home.intro', login_error=1)) is_remember = False if 'remember_me' not in request.form else True login_user(user_to_login, remember=is_remember) return redirect(url_for('home.home'))
def modify_password(): try: assert check_form_para(['old_password', 'new_password', 'new_password_conf']) assert UserHelper.verify_password(current_user, request.form['old_password']) except AssertionError, e: flash(e.message)