|
|
@@ -32,11 +32,11 @@ def login_post(): |
|
|
|
# take the user-supplied password, hash it, and compare it to the hashed password in the database |
|
|
|
if not user or not check_password_hash(user.password, password): |
|
|
|
flash('Please check your login details and try again.') |
|
|
|
return redirect(url_for('auth.login')) # if the user doesn't exist or password is wrong, reload the page |
|
|
|
return redirect(url_for('auth.login',_external=True)) # if the user doesn't exist or password is wrong, reload the page |
|
|
|
|
|
|
|
# if the above check passes, then we know the user has the right credentials |
|
|
|
login_user(user, remember=remember) |
|
|
|
return redirect(url_for('main.profile')) |
|
|
|
return redirect(url_for('main.profile',_external=True)) |
|
|
|
|
|
|
|
# routes for signup page |
|
|
|
@auth.route('/signup') |
|
|
@@ -53,7 +53,7 @@ def signup_post(): |
|
|
|
|
|
|
|
if user: # if a user is found, we want to redirect back to signup page so user can try again |
|
|
|
flash('Email address already exists') |
|
|
|
return redirect(url_for('auth.signup')) |
|
|
|
return redirect(url_for('auth.signup',_external=True)) |
|
|
|
|
|
|
|
# create a new user with the form data. Hash the password so the plaintext version isn't saved. |
|
|
|
new_user = User(email=email, name=name, password=generate_password_hash(password, method='sha256')) |
|
|
@@ -62,11 +62,11 @@ def signup_post(): |
|
|
|
db.session.add(new_user) |
|
|
|
db.session.commit() |
|
|
|
|
|
|
|
return redirect(url_for('auth.login')) |
|
|
|
return redirect(url_for('auth.login',_external=True)) |
|
|
|
|
|
|
|
# route for logout function |
|
|
|
@auth.route('/logout') |
|
|
|
@login_required |
|
|
|
def logout(): |
|
|
|
logout_user() |
|
|
|
return redirect(url_for('main.index')) |
|
|
|
return redirect(url_for('main.index',_external=True)) |