def login(): if request.method == 'GET': return render_template('login.html') elif request.method == 'POST': data = {} data["email"] = request.form["InputEmail"] result = checkUser(data) if (result["success"]): if (result["exists"]): hashed_password = result["user"]["password"] if (check_password(hashed_password, request.form["InputPassword"])): session['name'] = result["user"][ "firstName"] + ' ' + result["user"]["lastName"] session['email'] = result["user"]["email"] return redirect(url_for('manage_document')) flash('Invalid Login Credentials', { 'header': 'Sorry!!', 'class': 'alert-danger' }) return redirect(url_for('login')) else: flash('Some error occured. Please try again!', { 'header': 'Oops!!', 'class': 'alert-danger' }) return redirect(url_for('login'))
def home(): if request.method == 'POST': username = request.form['username'] password = request.form['password'] if (dbHandler.checkUser(username, password)): session['username'] = username return render_template('buyer.html') else: return render_template('index.html', error=True) return render_template('index.html', error=False) else: return render_template('index.html')
def POST(self, jumpPath=''): input = web.input(username=None, password=None) if not input.username or not input.password: return json.dumps({"Msg":"用户名或密码为空, 请检查!","rsCode":-1}) checkrs = models.checkUser(input.username, input.password) if not checkrs: return json.dumps({"Msg":"用户名或密码错误, 请检查!","rsCode":-2}) else: #set session session.islogin = True session.userInfo = checkrs return json.dumps({"Msg":"登陆成功", "rsCode":1})
def home(): if request.method == 'POST': username = request.form['username'] password = request.form['password'] if (dbHandler.checkUser(username, password)): session['username'] = username return redirect(url_for('dash')) #dbHandler.insertUser(session['username'], password) users = dbHandler.retrieveUsers() return render_template('index.html', users=users) else: return render_template('index.html')
def checkRegistrationForm(form): error = {} InputEmail = form['InputEmail'] InputPassword = form['InputPassword'] ConfirmPassword = form['ConfirmPassword'] if not (re.match(r'^(?=.*[A-Z])(?=.*[!@#$&*])(?=.*[0-9])(?=.*[a-z]).{8,}$', InputPassword)): error['InputPassword'] = '******' if (ConfirmPassword != InputPassword): error['ConfirmPassword'] = '******' result = checkUser({"email": InputEmail}) if result['success']: if result['exists']: error['InputEmail'] = 'User already exists' else: error['InternalError'] = 'Some internal error occured while validating email' return error
def register(): if request.method == 'GET': return render_template('register.html') elif request.method == 'POST': error = checkRegistrationForm(request.form) if error: return render_template('register.html', error=error) else: data = {} data['email'] = request.form['InputEmail'] result = checkUser(data) if result['success']: if result['exists']: flash('User already registered.', { 'header': 'Oops!!', 'class': 'alert-danger' }) return redirect(url_for('register')) else: data['firstName'] = request.form['InputFirstName'] data['lastName'] = request.form['InputLastName'] data['password'] = hash_password( request.form['InputPassword']) result = createUser(data) if result['success']: flash('User registered', { 'header': 'Success!!', 'class': 'alert-success' }) return redirect(url_for('login')) else: flash('Some error occured. Please try again!', { 'header': 'Oops!!', 'class': 'alert-danger' }) return redirect(url_for('register')) else: flash('Some error occured. Please try again!', { 'header': 'Oops!!', 'class': 'alert-danger' }) return redirect(url_for('register'))
def home(): if request.method == 'POST': username = request.form['username'] password = request.form['password'] count = dbHandler.checkUser(username, password) if count[0][0] >= 1: users = dbHandler.findGender(username) gender = users[0][0] data = dbHandler.retrieveUserDetails(gender) print(type(data)) if username == "admin": return render_template('admin.html', users=data) return render_template('dashboard.html', users=data, currentlogin=username) else: print("USER DOESNT EXIST") return render_template('welcome.html') else: return render_template('index.html')
def signup(): if request.method=='POST': username = request.form['username'] password = request.form['password'] re_password = request.form['repassword'] if ( password.lower() == re_password.lower()): if dbHandler.checkUser(username)==0: hash = generate_password_hash(password) dbHandler.insertUser(username, hash) session['username']=username return redirect("/GT") else: flash('Error: This username is unavailable. Try Again...') return render_template('signup.html') else: flash('Error: The passwords do not match. Try Again...') return render_template('signup.html') else: return render_template('signup.html')