Bläddra i källkod

removing signup

practices
Simon Bowie 1 år sedan
förälder
incheckning
dfb6892f46
2 ändrade filer med 19 tillägg och 22 borttagningar
  1. +19
    -19
      web/app/auth.py
  2. +0
    -3
      web/app/templates/base.html

+ 19
- 19
web/app/auth.py Visa fil

@@ -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')

+ 0
- 3
web/app/templates/base.html Visa fil

@@ -110,9 +110,6 @@
<a href="{{ url_for('auth.login') }}" class="block link">
Login
</a>
<a href="{{ url_for('auth.signup') }}" class="block link">
Sign Up
</a>
{% endif %}
{% if current_user.is_authenticated %}
<a href="{{ url_for('auth.logout') }}" class="block link">

Laddar…
Avbryt
Spara