Ejemplo n.º 1
0
    def post(self):

        form = auth_forms.LoginForm(request.form)
        authorized = False
        message = None

        if form.validate():

            authorized = auth_utils.check_password(form.password.data, form.email.data)

            if not authorized:
                message = "Invalid Email / Password"
            else:
                user = auth_models.WTUser.get_user_by_email(form.email.data)
                flask_login.login_user(user, remember=form.remember_me.data)

        else:
            message = "Invalid Email / Password"

        next_url = '/shipping/package_list'
        response = json.dumps(
            {
                'loggedin': authorized,
                'error_message': message,
                'next_url': next_url
            })
        return response
Ejemplo n.º 2
0
async def check_user_auth(db, email, password):
    collection = db[USER_COLLECTION]
    user = await get_by_email(collection=collection, email=email)
    if user:
        hash = user['hash']
        if check_password(password, hash):
            return user
    return False
Ejemplo n.º 3
0
    def post(self):

        form = auth_forms.LoginForm(request.form)
        error = None
        loggedin = False
        message = None

        if form.validate():

            loggedin = auth_utils.check_password(form.password.data, form.email.data)

            if not loggedin:
                message = "Invalid Email / Password"
            else:
                flask_login.login_user(auth_models.WTUser.all().filter('email =', form.email.data).fetch(1)[0],
                                       remember=form.remember_me.data)

        next_url = '/tournament/list'
        response = json.dumps({'loggedin': loggedin, 'error_message': message, 'next_url': next_url})
        return response