def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form email = request.form.get("email") password = request.form.get("password") if not customers.get_by_email(email): flash("Email not found.") return redirect("/login") else: customer = customers.get_by_email(email) if password == customer.password: session['logged_in_customer_email'] = email flash("successful login.") return redirect("/melons") else: flash("Check your password.") return redirect("/login")
def profile_page(): """Displays profile page of user. Provides links to change fields.""" if "login" in session: first_name = customers.get_by_email(session["login"]).first_name last_name = customers.get_by_email(session["login"]).last_name email = customers.get_by_email(session["login"]).email password = customers.get_by_email(session["login"]).password return render_template("profile.html", first_name=first_name, last_name=last_name, email=email, password=password)
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route # - if they don't, flash a failure message and redirect back to "/login" # - do the same if a Customer with that email doesn't exist import pdb pdb.set_trace() username = request.form['username'] password = request.form['password'] customer = customers.get_by_email(username) return "Oops! This needs to be implemented"
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ email = request.form.get('email') password = request.form.get('password') customers_list = customers.read_customers_from_file("customers.txt") if email in customers_list.keys(): customer = customers.get_by_email(email) if customer.password == password: flash("Login successful!") session['logged_in_customer_email'] = email session.get('logged_in_customer_email') return redirect("/melons") else: flash("The password you entered is incorrect.") return redirect("/login", logged_in_customer_email=logged_in_customer_email) else: flash("The email you entered does not match our records.") return redirect("/login", logged_in_customer_email=logged_in_customer_email)
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ email_submitted = request.form.get("email") password_submitted = request.form.get("password") # access customer_info dict in customers.py # use namespace customers.customer_info if email_submitted in customers.customer_info: customer = customers.get_by_email(email_submitted) if customer.password == password_submitted: session["logged_in_customer_email"] = email_submitted flash("Login successful.") return redirect("/melons") else: flash("Incorrect password.") return redirect("/login") else: flash("No such email.") return redirect("/login")
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # Get user's login credentials from login form email = request.form.get('email') password = request.form.get('password') # Look up if user exists in system user = customers.get_by_email(email) if user != None: # Verify if user provided correct password if user.is_correct_password(password): flash('Successfully logged in.') session['email'] = email return redirect('/melons') # Handle incorrect password flash('Incorrect username and/or password.') return redirect('/login') # Handle users not in system flash('Username does not exist.') return redirect('/login')
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # The logic here should be something like: # # - get user-provided name and password from request.form # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route # - if they don't, flash a failure message and redirect back to "/login" # - do the same if a Customer with that email doesn't exist session['email'] = request.form['email'] session['pw'] = request.form['password'] customer = get_by_email(session['email'], all_customers) if customer and customer.password == session['pw']: session['email'] = customer.email flash('Success! You have logged in!') return redirect('/melons') else: flash('Failure! You did not log in!') return redirect('/login')
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route # - if they don't, flash a failure message and redirect back to "/login" # - do the same if a Customer with that email doesn't exist email = request.form.get('email') password = request.form.get('password') customer = customers.get_by_email(email) print(email, password, customer) if not customer: flash('No customer with that email found.') else: if customer.password == password: session['user'] = email flash('Login successful!') return redirect('/melons') else: flash('Incorrect password.') return redirect('/login')
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route # - if they don't, flash a failure message and redirect back to "/login" # - do the same if a Customer with that email doesn't exist username = request.form['email'] password = request.form['password'] customer = customers.get_by_email(username) if customer: if password == customer.password: flash("You are logged in!") return redirect('/melons') else: flash("Wrong Password") return redirect('/login') else: flash("Are you sure that is your email?") return redirect('/login')
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route # - if they don't, flash a failure message and redirect back to "/login" # - do the same if a Customer with that email doesn't exist password = request.form.get("password") email = request.form.get("email") customer = customers.get_by_email("customers.txt", email) if customer and customer.password == password: flash(f"Successfully logged in as {customer.first}") return redirect("/melons") flash("Login failed") return redirect("/login")
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! email = request.form.get("email") password = request.form.get("password") customer = customers.get_by_email(email) customer_info = { 'first name': customer.first_name, 'last name': customer.last_name, 'email': customer.email, 'password': customer.password } if customer and password == customer.password: # import pdb; pdb.set_trace() session['email'] = customer_info flash("You have logged in") return redirect("/melons") else: flash("Invalid username/password") return redirect("/login")
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route # - if they don't, flash a failure message and redirect back to "/login" # - do the same if a Customer with that email doesn't exist email = request.form['email'] password = request.form['password'] customer = customers.get_by_email(email) if customer and customer.password == password: session['current-user'] = email flash("Logged in as {}".format(email)) return redirect("/melons") else: flash("Invalid email or password.") return redirect("/login")
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ email = request.form.get("email") password = request.form.get("password") if customers.get_by_email(email) == False: flash("No user email found.") elif customers.get_by_email(email).password != password: flash("Incorrect Password") elif customers.get_by_email(email).password == password: session["logged_in_customer_email"] = email flash("Login successful!") return render_template("all_melons.html")
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ email = request.form["email"] password = request.form["password"] if customers.get_by_email(email): if hash(password) == customers.get_by_email(email).hashed_password : session["logged_in_customer_email"] = email flash("Login successful") return redirect ('/melons') else: flash("Login unsuccessful") return redirect ('/login') else: flash("No customer with that email found.") return redirect('/login')
def edit_password_name(): first_name = customers.get_by_email(session["login"]).first_name last_name = customers.get_by_email(session["login"]).last_name email = customers.get_by_email(session["login"]).email password = customers.get_by_email(session["login"]).password confirm_password = request.form.get("confirm-password") desired_password = request.form.get("desired-password") if password == confirm_password: for i, line in enumerate(fileinput.input('customers.txt', inplace=1)): sys.stdout.write(line.replace(first_name+"|"+last_name+"|"+email+"|"+password, first_name+"|"+last_name+"|"+email+"|"+desired_password)) flash("Your password has been updated") else: flash("Incorrect password") return redirect("/profile")
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route # - if they don't, flash a failure message and redirect back to "/login" # - do the same if a Customer with that email doesn't exist user_email = request.form.get('email') if customers.get_by_email(user_email): current_customer = customers.get_by_email(user_email) print(current_customer.email) if current_customer.password == request.form.get('password'): session['user'] = user_email flash( "You've logged in successfully. Welcome to your Ubermelons account." ) return redirect('/melons') else: flash('Incorrect Password. Please try again') return redirect('/melons') else: flash( "no account with that email exists. please create one or try again" ) return redirect('/login')
def edit_password_name(): first_name = customers.get_by_email(session["login"]).first_name last_name = customers.get_by_email(session["login"]).last_name email = customers.get_by_email(session["login"]).email password = customers.get_by_email(session["login"]).password confirm_password = request.form.get("confirm-password") desired_password = request.form.get("desired-password") if password == confirm_password: for i, line in enumerate(fileinput.input('customers.txt', inplace=1)): sys.stdout.write( line.replace( first_name + "|" + last_name + "|" + email + "|" + password, first_name + "|" + last_name + "|" + email + "|" + desired_password)) flash("Your password has been updated") else: flash("Incorrect password") return redirect("/profile")
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form email = request.form.get("email") password = request.form.get("password") print(request.form) # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) customer_info = get_by_email(email) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route if customer_info: if password == customer_info.password: session['email'] = email flash("Success! You've been logged in.") return redirect("/melons") # - if they don't, flash a failure message and redirect back to "/login" else: flash("Sorry, you cannot be logged in. Please try again.") return redirect("/login") else: flash("Sorry, you cannot be logged in. Please try again.") return redirect("/login") # - do the same if a Customer with that email doesn't exist return "Oops! This needs to be implemented"
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ email = request.form.get("email") password = request.form.get("password") user = customers.get_by_email(email) if user.password == password: flash("You're successfully logged in") return redirect('/melons') else: flash("Invalid password") return redirect('/login')
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route # - if they don't, flash a failure message and redirect back to "/login" # - do the same if a Customer with that email doesn't exist name = request.form['email'] password = request.form['password'] if name not in customers.customers: flash('emailed not matched in database') return redirect('login') else: customer = customers.get_by_email(name) if password == customer.password: session['password'] = password flash('sucess') return redirect('/melons') else: flash('incorrect password') return redirect('/login') # if name != customer.email: # flash('emailed not matched in database') # return redirect('login') return "Oops! This needs to be implemented"
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ email = request.form["email"] password = request.form["password"] user = customers.get_by_email(email) if user: if user.password != password: flash("Incorrect password") return redirect("/login") session["email"] = email flash("Welcome to Ubermelon!") return redirect("/melons") else: flash("No customer with that email found.") return redirect("/login")
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! user_email = request.form.get('email') user_pw = request.form.get('password') try: user = customers.get_by_email(user_email) if user_pw == user.password: # log them in flash("You are logged in.") # redirect to /melons else: flash("Incorrect password.") #redirect to login page except KeyError: flash("User not found! Please create account.")
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route # - if they don't, flash a failure message and redirect back to "/login" # - do the same if a Customer with that email doesn't exist # - ImmutableMultiDict{'email':'*****@*****.**', 'password':'******'} login_attempt = request.form print('\n \n \n \n') print(login_attempt) print('\n \n \n \n') if login_attempt['email'] in customers.customer_dictionary: user = customers.get_by_email(login_attempt['email']) if user.password == login_attempt['password']: flash("Login Successful!") return redirect("/melons") else: flash("Incorrect Password") return redirect("/login") else: flash("User Not Found") return redirect("/login")
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route # - if they don't, flash a failure message and redirect back to "/login" # - do the same if a Customer with that email doesn't exist username = request.form.get("email") password = request.form.get("password") print(username, password) customer_object = get_by_email(username) print(customer_object) if customer_object: if password == customer_object.password: session["logged_in_customer_email"] = username flash("Login successful!") return redirect("/melons") else: flash("Incorrect password") return redirect("/login") else: flash("No customer with that email found") return redirect("/login")
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route # - if they don't, flash a failure message and redirect back to "/login" # - do the same if a Customer with that email doesn't exist #get inputs of username and password username = request.form['email'] password = request.form['password'] #check if that email is tied to a customer customer = customers.get_by_email(username) #get_by_email returns False if customer doesn't exist # if customer exists and their password matches # log them in and add email to session if customer is not False and customer.password == password: session['user_email'] = customer.email flash("You have successfully logged in!") return redirect('/melons') else: print "elsing!" flash("That username or password is incorrect! Try again.") return redirect('/login')
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ email = request.form.get("email") password = request.form.get("password") customer = customers.get_by_email(email) if customer is not None: if customer.is_correct_password(password): session["email"] = email flash("Login Successful!") return redirect("/melons") else: flash("Incorrect Password") return redirect("/login") else: flash("User Does Not Exist") return redirect("/login")
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route # - if they don't, flash a failure message and redirect back to "/login" # - do the same if a Customer with that email doesn't exist email = request.form['email'] password = request.form['password'] customer = customers.get_by_email(email) if customer: if customer.password == password and customer.email == email: if 'logged_in_customer_email' in session: session['logged_in_customer_email'].append(email) else: session['logged_in_customer_email'] = [email] flash("You have successfully logged in.") return redirect('/melons') else: flash("Incorrect password. Please try again.") return redirect('/login') else: flash("No customer with that email found. Please try again.") return redirect('/login')
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ cust_email = request.form.get("email") cust_pass = request.form.get("password") customer = customers.get_by_email(cust_email) if customer: if cust_pass == customer.password: session["credentials"] = customer.email flash("Welcome back {}!".format(customer.first_name)) return redirect("/melons") flash("The e-mail address and/or password you specified are not correct.") return redirect("/login")
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ email = request.form.get('email') password = request.form.get('password') user = customers.get_by_email(email) if not user: flash("No such email address.") return redirect('/login') if user.password != password: flash("Incorrect password.") return redirect("/login") session["logged_in_customer_email"] = user.email flash("Logged in.") return redirect("/melons")
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ email = request.form.get('email') password = request.form.get('password') try: customer = customers.get_by_email(email) except: flash('A user with that email does not exist. Try again.') return redirect('/login') if customer.is_hashed_password(password): session['user'] = email flash('Welcome, {}!'.format(customer.first_name)) return redirect('/melons') else: flash('Invalid password for {}'.format(email)) return redirect('/login')
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route # - if they don't, flash a failure message and redirect back to "/login" # - do the same if a Customer with that email doesn't exist email = request.form["email"] if email not in customers_mod.customers: flash("No customer with that email found.") return redirect(url_for("process_login")) # customers.get_by_email(email) == email: password = request.form["password"] if customers_mod.get_by_email(email).password == password: session['logged_in_customer_email'] = email flash("Login successful!") return redirect(url_for("list_melons")) else: flash("Incorrect password") return redirect(url_for("process_login"))
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form user_email = request.form.get('email') user_password = request.form.get('password') # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route # - if they don't, flash a failure message and redirect back to "/login" # - do the same if a Customer with that email doesn't exist if user_email in customers.customer_info: user = customers.get_by_email(user_email) if user.password == user_password: flash("Success!") session['email'] = user_email return redirect('/melons') flash("Incorrect") return redirect('/login')
def process_login(): email = request.form["email"] password = request.form["password"] customer = customers.get_by_email(email) if customer is not None: if password == customer.password: flash("login successfull") session['logged_in_customer_email'] = email return redirect("/melons") else: flash("incorrect password") return redirect("/login") else: flash("No customer with that email found.") return redirect('/login') """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route # - if they don't, flash a failure message and redirect back to "/login" # - do the same if a Customer with that email doesn't exist return "Oops! This needs to be implemented"
def process_login(): """Log user into site. Find the user's login credentials located in the 'request.form' dictionary, look up the user, and store them in the session. """ # TODO: Need to implement this! # The logic here should be something like: # # - get user-provided name and password from request.form # - use customers.get_by_email() to retrieve corresponding Customer # object (if any) # - if a Customer with that email was found, check the provided password # against the stored one # - if they match, store the user's email in the session, flash a success # message and redirect the user to the "/melons" route # - if they don't, flash a failure message and redirect back to "/login" # - do the same if a Customer with that email doesn't exist username = request.form['email'] entered_password = request.form['password'] if username in customers.read_customers_from_file("customers.txt"): customer = customers.get_by_email(username) if entered_password == customer.password: session['email'] = customer.email flash("You successfully logged in.") return redirect("/melons") else: flash("Wrong password, try again.") return redirect("/login") else: flash("User/password not found. Try again.") return redirect("/login")
def first_name_creation(): if "login" in session: first_name = customers.get_by_email(session["login"]).first_name return dict(first_name=first_name) else: return dict(first="hello")