コード例 #1
0
def login():
    form = LoginUserForm(request.form)
    if request.method == 'POST' and form.validate():
        username = form.data['username']
        login_user(User.get_by_username(username))
        flash(f'Welcome {username}!')
        return redirect('/')
    return render_template('forms/login.html', form=form)
コード例 #2
0
ファイル: forms.py プロジェクト: annshress/movquiz
 def validate(self):
     success = super().validate()
     if not success:
         return False
     user = User.get_by_username(self.data['username'])
     if not user:
         self.errors['errors'] = ['User not found.']
         return False
     elif not user.check_password(password=self.data['password']):
         self.password.errors.append('Password does not match')
         return False
     return True