def login_process(): logform = LogForm() session.pop('_flashes', None) error = "There is a problem were you are not successfully logged in" print("Thank you") if request.method == 'POST': email = request.form['email'].lower() password = request.form['password'].lower() data = Database.find_one(userconstants.COLLECTION, {"email": email}) active = Database.find_one(userconstants.COLLECTION, {"email": email}) if active['active'] == 1 and Users.login_valid( request.form['email'], request. form['password']) != False and utils.check_hash_password( password, data['password']) == True: print("I am in the prent") response = make_response(redirect(url_for('welcome'))) response.set_cookie('login_email', request.form['email']) response.set_cookie('login_author', data['firstname']) response.set_cookie('login_id', data['_id']) return response else: flash("some wrong") return redirect(url_for('logout')) flash('There is a problem were you are not successfully logged in') print("heee") return render_template('login.html')
def login_process(): session.pop('_flashes', None) if request.method == 'POST': email = request.form['email'].lower() password = request.form['password'].lower() data = Database.find_one(UserConstants.COLLECTION,{"email":email}) if Users.login_valid(request.form['email'],request.form['password']) != False and utils.check_hash_password(password,data['password']) == True: response = make_response(redirect(url_for('welcome'))) response.set_cookie('login_email', request.form['email']) response.set_cookie('login_author', data['firstname']) response.set_cookie('login_id', data['_id']) return response else: error = "You are not a valiable user" flash("There is a problem were you are not successfully logged in") render_template('login.html', title='login', logform=logform, error=error) flash('There is a problem were you are not successfully logged in') return render_template('login.html', title='login', logform=logform, error=error)
def login_user(): error = None if request.method == 'POST': email = request.form['email'] password = request.form['password'] if Users.login_valid(request.form['email'],request.form['password']): user = Users.login(email) img = File_system.image(email) flash("you have Succesfuly logged in") response = make_response(redirect(url_for('welcome',email=request.form.get('email'),image=img['image'],id=img['_id']))) response.set_cookie('email',request.form.get('email')) return response else: error = 'User'+" "+ request.form['email']+" "+'does not exist' session['email'] = None return render_template("login.html",error=error) return render_template("profile.html", email=request.form.get('email'))