def login(): #wtforms not needed here if request.method == 'POST': inbound_username = request.form['username'] existing_user = search_user_by_username(inbound_username) if (existing_user is None): app.logger.info("NO USER") error = "Username or Password is incorrect! Username is case sensitive" return render_template('login.html', error=error) elif (sha256_crypt.verify(request.form['password'], existing_user['password'])): app.logger.info("PASSWORD MATCHED,LOGGING IN") session['user_id'] = str(existing_user['_id']) session['account_type'] = existing_user['account_type'] session['username'] = existing_user['username'] flash('Login Sucessful!', 'success') return redirect(url_for('dashboard')) else: app.logger.info("WRONG PASSWORD") error = "Username or Password is incorrect!" return render_template('login.html', error=error) if ("user_id" in session.keys()): return render_template('dashboard.html') return render_template('login.html')
def login(): inbound_username = request.form["username"] existing_user = search_user_by_username(inbound_username) if (existing_user is None): return render_template('signuperror.html') elif (request.form["password"] == existing_user["password"]): print("Login succesful, showing you the project page") session['user_id'] = str(existing_user['_id']) return redirect(url_for('index')) else: return render_template('loginerror.html')
def login(): inbound_username = request.form["username"] existing_user = search_user_by_username(inbound_username) if(existing_user is None): return render_template('error.html', message="You have to sign up first") elif(request.form["password"] == existing_user["password"]): print ("Login successful. Redirecting to products page") session['user_id'] = str(existing_user['_id']) session['account type'] = str(existing_user['account type']) return redirect(url_for('index')) else: return render_template('error.html', message="username or password not correct")