|
|
@@ -39,31 +39,31 @@ def login_post(): |
|
|
|
login_user(user, remember=remember) |
|
|
|
return redirect(url_for('main.profile',_external=True,_scheme=os.environ.get('SSL_SCHEME'))) |
|
|
|
|
|
|
|
# routes for signup page |
|
|
|
@auth.route('/signup') |
|
|
|
def signup(): |
|
|
|
return render_template('signup.html') |
|
|
|
# # routes for signup page |
|
|
|
# @auth.route('/signup') |
|
|
|
# def signup(): |
|
|
|
# return render_template('signup.html') |
|
|
|
|
|
|
|
@auth.route('/signup', methods=['POST']) |
|
|
|
def signup_post(): |
|
|
|
email = request.form.get('email') |
|
|
|
name = request.form.get('name') |
|
|
|
password = request.form.get('password') |
|
|
|
# @auth.route('/signup', methods=['POST']) |
|
|
|
# def signup_post(): |
|
|
|
# email = request.form.get('email') |
|
|
|
# name = request.form.get('name') |
|
|
|
# password = request.form.get('password') |
|
|
|
|
|
|
|
user = User.query.filter_by(email=email).first() # if this returns a user, then the email already exists in database |
|
|
|
# user = User.query.filter_by(email=email).first() # if this returns a user, then the email already exists in database |
|
|
|
|
|
|
|
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',_external=True,_scheme=os.environ.get('SSL_SCHEME'))) |
|
|
|
# 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',_external=True,_scheme=os.environ.get('SSL_SCHEME'))) |
|
|
|
|
|
|
|
# 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='scrypt')) |
|
|
|
# # 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='scrypt')) |
|
|
|
|
|
|
|
# add the new user to the database |
|
|
|
db.session.add(new_user) |
|
|
|
db.session.commit() |
|
|
|
# # add the new user to the database |
|
|
|
# db.session.add(new_user) |
|
|
|
# db.session.commit() |
|
|
|
|
|
|
|
return redirect(url_for('auth.login',_external=True,_scheme=os.environ.get('SSL_SCHEME'))) |
|
|
|
# return redirect(url_for('auth.login',_external=True,_scheme=os.environ.get('SSL_SCHEME'))) |
|
|
|
|
|
|
|
# route for logout function |
|
|
|
@auth.route('/logout') |