示例#1
0
def login_post():
    r = flask.request

    email = r.form.get('email', '').lower().strip()
    password = r.form.get('password', '').strip()

    if not email or not password:
        return {
            'email': email,
            'password': password,
            'error': "Some required fields are missing."
        }

    # TODO: Validate the user
    user = user_service.login_user(email, password)
    if not user:
        return {
            'email': email,
            'password': password,
            'error': "The account does not exist or the password is wrong."
        }

    resp = flask.redirect('/account')
    cookie_auth.set_auth(resp, user.id)

    return resp
def login_post():
    data = request_dict.create(default_val='')

    email = data.email.lower().strip()
    password = data.password.strip()

    if not email or not password:
        return {
            'email': email,
            'password': password,
            'error': "Some required fields are missing.",
            'user_id': cookie_auth.get_user_id_via_auth_cookie(flask.request),
        }

    user = user_service.login_user(email, password)
    if not user:
        return {
            'email': email,
            'password': password,
            'error': "The account does not exist or the password is wrong.",
            'user_id': cookie_auth.get_user_id_via_auth_cookie(flask.request),
        }

    resp = flask.redirect('/account')
    cookie_auth.set_auth(resp, user.id)

    return resp
 def login_user(self) -> flask.Response:
     self.user = login_user(self.email_address, self.password)
     if self.user:
         # Redirect to the account page, but do it as a logged in session (where user has a cookie telling us we're in a
         # session)
         resp = flask.redirect("/account")
         cookie_auth.set_auth(resp, self.user.id)
         return resp
     else:
         self.error = "Invalid email address or password"
         return flask.render_template("/account/login.html", **self.to_dict())
示例#4
0
def login_post():
    vm = LoginViewModel()
    vm.validate()
    if vm.error:
        return vm.to_dict()

    user = user_service.login_user(vm.email, vm.password)
    if not user:
        vm.error = "The account does not exist or the password is wrong."
        return vm.to_dict()

    resp = flask.redirect('/account')
    cookie_auth.set_auth(resp, user.id)

    return resp
def login_post():
    vm = LoginViewModel()
    vm.validate()

    if vm.error:
        log.notice(f"User could not log in, error: {vm.email} - {vm.error}.")
        return vm.to_dict()

    user = user_service.login_user(vm.email, vm.password)
    if not user:
        vm.error = "The account does not exist or the password is wrong."
        log.notice(f"User could not log in, error: {vm.error}.")
        return vm.to_dict()

    resp = flask.redirect('/account')
    cookie_auth.set_auth(resp, user.id)

    log.notice(f"User SUCCESSFULLY logged in account: {user.name} - {user.email}.")
    return resp
def login_post():
    r = flask.request
    email = r.form.get("email")
    password = r.form.get("password")

    if not email or not password:
        return {
            "error": "Some required fields are missing",
            "email": email,
            "password": password
        }
    user = user_service.login_user(email, password)
    if not user:
        return {
            "error": "The user does not exist or the password is wrong",
            "email": email,
            "password": password
        }
    resp = flask.redirect("/account")
    cookie_auth.set_auth(resp, user.id)
    return resp
示例#7
0
def login_post():
    r = flask.request
    email = r.form.get('email', '').lower().strip()
    password = r.form.get('password', '').strip()

    if not email or not password:
        return {
            'error': 'Some required fields are missing.',
            'email': email,
            'password': password
        }

    user = user_service.login_user(email, password)
    if not user:
        return {
            'error': 'Account does not exist, or password is incorrect',
            'email': email,
            'password': password
        }

    resp = flask.redirect('/account')
    cookie_auth.set_auth(resp, user.id)

    return resp