GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

LoginForm.validate()   A
last analyzed

Complexity

Conditions 4

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
c 1
b 0
f 0
dl 0
loc 19
rs 9.2
1
from flask_wtf import Form
2
from wtforms import StringField, PasswordField
3
from wtforms import validators
4
5
from sugarloaf.models import User
6
7
8
class LoginForm(Form):
9
    username = StringField(u'Username', validators=[validators.required()])
10
    password = PasswordField(u'Password', validators=[validators.optional()])
11
12
    def validate(self):
13
        check_validate = super(LoginForm, self).validate()
14
15
        # if our validators do not pass
16
        if not check_validate:
17
            return False
18
19
        # Does our the exist
20
        user = User.query.filter_by(username=self.username.data).first()
21
        if not user:
22
            self.username.errors.append('Invalid username or password')
23
            return False
24
25
        # Do the passwords match
26
        if not user.check_password(self.password.data):
27
            self.username.errors.append('Invalid username or password')
28
            return False
29
30
        return True
31