def register(): if request.method == "POST": names = request.form["names"] email = request.form["email"] password = request.form["password"] password = generate_password_hash(password) User.create(names=names, email=email, password=password) flash("Account Created Successfully") return render_template("register.html")
def signup(): if request.method == "POST": names = request.form["name"] unames = request.form["username"] astyle = request.form["style"] email = request.form["email"] password = request.form["pwd"] password = generate_password_hash(password) User.create(names=names, username=unames, style=astyle, email=email, password=password) flash("Account Created Successfully") return render_template("SIGNUP.html")
def profile(): if not session.get('logged_in'): return redirect(url_for('login')) if request.method == "POST": names = request.form["names"] username = request.form["username"] email = request.form["email"] style = request.form["style"] users = User.select() return render_template('PROFILE.html')
def login(): if request.method == "POST": email = request.form["email"] password = request.form["password"] try: user = User.get(User.email == email) hashed_password = user.password if check_password_hash(hashed_password, password): flash("Logged in Successfully") session['logged_in'] = True session['names'] = user.names session['id'] = user.id return redirect(url_for('show')) except User.DoesNotExist: flash("Wrong Username or Password") return render_template("login.html")
def login(): if request.method == ['POST']: email = request.form["email"] password = request.form["pwd"] try: user = User.get(User.email == email) hashed_password = user.password if check_password_hash(hashed_password, password): flash("Logging in") session['logged_in'] = True session['names'] = user.names session['id'] = user.id return redirect(url_for('PROFILE')) except User.DoesNotExist: flash("Wrong Email/Username or password") return render_template('LOGIN.html')