Example #1
0
def do_login():
    try:
        user = User.query.filter(User.username == request.form["username"]).one()
    except NoResultFound:
        return ["User not found"]
    if user.password != hash_password(request.form["password"]):
        return ["Wrong password"]
    login_user(user)
    return []
Example #2
0
def do_login():
    try:
        user = User.query.filter(
            User.username == request.form['username']).one()
    except NoResultFound:
        return ['User not found']
    if user.password != hash_password(request.form['password']):
        return ['Wrong password']
    login_user(user)
    return []
Example #3
0
    def run(self, password):
        team = self.get_team()

        sess = db.session()
        has_admin = sess.query(User.query.filter(User.username == 'admin').
                               exists()).scalar()
        if not has_admin:
            user = User(username='******', password=hash_password(password),
                        admin=True, team_id=team.id)
            sess.add(user)
            sess.commit()
        else:
            print("User admin is already exists")
Example #4
0
def do_login():
    try:
        user = User.query.filter(
            User.username == request.form['username']).one()
    except NoResultFound:
        return ['User not found']
    if user.password != hash_password(request.form['password']):
        return ['Wrong password']
    login_user(user)
    return []


CHANGE_PASSWORD_FORM = t.Dict({
    'oldpassword':
    t.String(allow_blank=True) >> (lambda x: x if hash_password(
        x) == g.user.password else t.DataError('Wrong old password')),
    KeysSubset('password1', 'password2'): (lambda x: {
        'password':
        hash_password(x['password1']) if x['password1'] == x['password2'] else
        t.DataError('Passwords does not match')
    })
}).ignore_extra('_csrf_token', 'submit')


@auth.route('profile', methods=['GET', 'POST'])
@login_required
def profile():
    g.errors = []
    message = None
    if request.method == 'POST':
        if request.form['submit'] == 'change_password':
Example #5
0
def do_login():
    try:
        user = User.query.filter(User.username == request.form["username"]).one()
    except NoResultFound:
        return ["User not found"]
    if user.password != hash_password(request.form["password"]):
        return ["Wrong password"]
    login_user(user)
    return []


CHANGE_PASSWORD_FORM = t.Dict(
    {
        "oldpassword": t.String(allow_blank=True)
        >> (lambda x: x if hash_password(x) == g.user.password else t.DataError("Wrong old password")),
        KeysSubset("password1", "password2"): (
            lambda x: {
                "password": hash_password(x["password1"])
                if x["password1"] == x["password2"]
                else t.DataError("Passwords does not match")
            }
        ),
    }
).ignore_extra("_csrf_token", "submit")


@auth.route("profile", methods=["GET", "POST"])
@login_required
def profile():
    g.errors = []