def login_post(): data = request_dict.create() 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), } # 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', 'user_id': cookie_auth.get_user_id_via_auth_cookie(flask.request), } # TODO: log in browser as a session resp = flask.redirect('/account') cookie_auth.set_auth(resp, user.id) return resp
def login_post(): # TODO: create view model for login data = request_dict.create() r = flask.request email = data.email.lower().strip() password = data.password.strip() if not email or not password: return { 'email': email, 'password': password, 'error': "Some require fields are missing", } 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 register_post(): data = request_dict.create(default_val='') name = data.name email = data.email.lower().strip() password = data.password.strip() if not name or not email or not password: return { 'name': name, '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.create_user(name, email, password) if not user: return { 'name': name, 'email': email, 'password': password, 'error': "A user with that email already exists.", '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 __init__(self): self.request: Request = flask.request self.request_dict = request_dict.create('') self.error: Optional[str] = None self.user_id: Optional[int] = cookie_auth.get_user_id_via_auth_cookie( self.request)
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" } # 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 incorrect" } resp = flask.redirect(url_for('account.index')) cookie_auth.set_auth(resp, user.id) return resp
def __init__(self): self.request: Request = flask.request self.request_dict = request_dict.create("") self.error: Optional[str] = None