def login(self, request): """ It gets the users login credentials from the form and then sends it to the database """ if request.method == 'POST': email = request.form['email'] password = request.form['password'] error = None if not email: error = 'An email is required.' elif not password: error = 'Password is required.' else: try: database = Database() user = database.login(email, password) # TODO Remove for production #flask_app.logger.info(user) self.user.set_user(user) except Exception as err: error = err if error: raise Exception(error) else: return
def login(self, request): """ login method. Processes POST request, and logs the user into Firebase upon success. """ # Request is sent to Firebase DB. if request.method == 'POST': email = request.form['email'] password = request.form['password'] # Validates required login fields. error = None if not email: error = 'An email is required.' elif not password: error = 'Password is required.' else: try: database = Database() user = database.login(email, password) # TODO Remove for production #flask_app.logger.info(user) self.user.set_user(user) except Exception as err: error = err if error: # Raise error from failed Firebase request. raise Exception(error) else: # Return on success. return
def login(self, request): """ Attempts to login using user credentials """ if request.method == 'POST': email = request.form['email'] password = request.form['password'] error = None # When email field is not filled in. if not email: error = 'An email is required.' # When password field is not filled in. elif not password: error = 'Password is required.' else: try: database = Database() user = database.login(email, password) # TODO Remove for production #flask_app.logger.info(user) self.user.set_user(user) except Exception as err: error = err if error: raise Exception(error) else: return
def login(self, request): if request.method == 'POST': # reuqests form infomation for email, and password. email = request.form['email'] password = request.form['password'] error = None if not email: # No email gotten in the request, push readable error error = 'An email is required.' elif not password: # No password pulled in the request, push readable error error = 'Password is required.' else: try: # Pulls infomation about email and password from database. database = Database() user = database.login(email, password) # TODO Remove for production #flask_app.logger.info(user) self.user.set_user(user) except Exception as err: error = err if error: raise Exception(error) else: return
def login(self, request): if request.method == 'POST': email = request.form['email'] password = request.form['password'] #If a email or password hasnt been provided error is provided. error = None if not email: error = 'An email is required.' elif not password: error = 'Password is required.' else: try: #Sends request if email and password is provided database = Database() user = database.login(email, password) # TODO Remove for production #flask_app.logger.info(user) self.user.set_user(user) except Exception as err: error = err if error: raise Exception(error) # Raise error from failed Firebase request else: # Return on success return