def registration(): messages = [] if request.method=='POST': username = request.form['username'] password = request.form['password'] #check username length if len(username) < 8: messages.append("Invallid username- usernames must be at least 8 characters in length.") if len(username) > 20: messages.append("Invallid username- The entered username is too long. Usernames must be 20 characters or less in length.") #check password length if len(password) < 8: messages.append("Invallid password- passwords must be at least 8 characters long.") if len(password) > 20: messages.append("Invallid password- The password you entered is too long. Passwords must not be longer than 20 characters in length.") #if no error messages if len(messages) != 0: #return registration page with new error message(s) return render_template('registration.html', messages=messages) if dbHandler.userExists(username) == True: messages.append("UserAlready exists") return render_template('registration.html', messages=messages) else: #insert new user dbHandler.insertUser(username, password) session['username'] = username return redirect(url_for('user')) else: return render_template('registration.html', messages=messages)
def signUp(): if 'logged_in' in session: return redirect(url_for("friends")) if request.method == "POST": email=str(request.form['email']) fname=str(request.form['fname']) lname=str(request.form['lname']) phone=str(request.form['phone']) name=fname + " " + lname password=str(request.form['pass']) conpassword=str(request.form['conpass']) Pass=hashlib.sha256(password) hashPass=Pass.hexdigest() user1 = dbHandler.getUser(email) user2 = dbHandler.getUser(phone) if password == conpassword: if user1 : flash("Email-ID Already Exists.",'danger') redirect(url_for("signUp")) elif user2 : flash("Phone Number Already Exists.",'danger') return render_template("signup.html") else: dbHandler.insertUser(email,name,hashPass,phone) return redirect(url_for("login")) else: flash("Password don't match",'danger') return render_template("signup.html") return render_template("signup.html")
def register_page(): if request.method == "GET": return render_template("register.html") if request.method == 'POST': username = request.form['inputName'] country = request.form['inputCountry'] birthday = request.form['inputDateOfBirth'] gender = request.form['genders'] password = request.form['inputPassword'] confirmPassword = request.form['inputConfirmPassword'] if password == confirmPassword: userId = dbHandler.getUserId(username) if len(userId) == 1: flash("Username already exists") return render_template('register.html') else: dbHandler.insertUser(username, password, country, birthday, gender) userId = dbHandler.getUserId(username) session['logged_in'] = True session['username'] = username session['userid'] = userId[0][0] return redirect(url_for('home')) else: flash("Password must match") return render_template('register.html')
def hello(): form = ReusableForm(request.form) print form.errors if request.method == 'POST': name = request.form['name'] password = request.form['password'] email = request.form['email'] member_id = request.form['member_id'] loan_amount = request.form['loan_amount'] funded_amount = request.form['funded_amount'] term = request.form['term'] print(name, " ", email, " ", password) print(member_id, " ", loan_amount, " ", funded_amount, " ", term) if form.validate(): # Save the comment here. flash('Thanks for registration ' + name) # Insert a row of data dbHandler.insertUser(member_id, loan_amount, funded_amount, term) else: flash('Error: All the form fields are required. ') return render_template('index.html', form=form)
def home(): if request.method == 'POST': username = request.form['username'] password = request.form['password'] dbHandler.insertUser(username, password) users = dbHandler.retrieveUsers() return render_template('index.html', users=users) else: return render_template('index.html')
def home(): if request.method=='POST': username = request.form['username'] password = request.form['password'] dbHandler.insertUser(username, password) users = dbHandler.retrieveUsers() return render_template('index.html', users=users) else: return render_template('index.html')
def signup(): if request.method=='POST': username = request.form['username'] password = request.form['password'] session['user'] = username dbHandler.insertUser(username, password) users = session['user'] return render_template('thanks.html', users=username) else: return render_template('signup.html')
def createnew(): if request.method == 'POST': username = request.form['username'] password = request.form['password'] email = request.form['email'] phone = request.form['phone'] district = request.form['district'] session['username'] = username dbHandler.insertUser(email, username, password, phone, district) return redirect(url_for('home'))
def kate_page(): if request.method == 'POST': username = request.form['username'] password = request.form['password'] dbHandler.insertUser(username, password) users = dbHandler.retrieveUsers() # conn.row_factory = sql.Row conn = psycopg2.connect(DATABASE_URL, sslmode='require') cur = conn.cursor() cur.execute("SELECT * FROM seating") people = cur.fetchall() # [(id, name, table_no)] cur.execute("SELECT name, relationship FROM people_attr") res = cur.fetchall() # scoring ... pref = {} for name, rel in res: rel = rel.lower() rels = pref.get(rel, []) rels.append(name) pref[rel] = rels pref['weight'] = { 'friend' : 2, 'acquaintance' : 1, 'empty' : 0, 'stranger' : -1, 'enemy' : -2 } table={} for (pid, name, table_no) in people: t = table.get(table_no, {'person':[]}) t['person'].append(name) table[table_no] = t rank = sort_table(pref, table) #print(rank) table_map = {} for p in people: cur.execute("SELECT relationship, class_year, major, misc FROM people_attr WHERE name LIKE '%{}%'".format(p[1])) people_list = table_map.get(p[2], []) people_list.append((p[1], cur.fetchone())) table_map[p[2]] = people_list cur.close() conn.close() print(table_map) # reorder table_map ... table_map = [ (tno,table_map[tno]) for (score,tno) in rank] empty_tables = [i for i in range(1, 10) if i not in list(zip(*table_map))[0]] return render_template("list_tables.html", all_tables=table_map, empty_tables=empty_tables)
def register_page(): form = UserRegistrationForm(request.form) if request.method == "POST" and form.validate(): st_id = form.st_id.data st_loc = form.st_loc.data st_iname = form.st_iname.data m = str(form.password.data) opassword = hashlib.md5(m.encode()) password = opassword.hexdigest() dbHandler.insertUser(st_id, st_loc, password, st_iname) return redirect(url_for('login')) return render_template("admin.html", form=form)
def createnew(): if request.method == 'POST': username = request.form['username'] password = request.form['password'] email = request.form['email'] #userlist=dbHandler.retrieveUsers() #if username in userlist[0]: # return redirect(url_for('createnew')) session['username'] = username dbHandler.insertUser(email, username, password) return redirect(url_for('home'))
def signup(): if request.method == 'POST': username = request.form['username'] password = getHash(request.form['password']) checkUsername = dbHandler.checkUsername(username) print(len(dbHandler.checkUsername(username))) if (len(checkUsername) != 0): print("Error") return render_template('login.html', checkUsername=checkUsername) else: dbHandler.insertUser(username, password) users = dbHandler.retrieveUsers(username, password) return render_template('login.html', users=users)
def createnew(): if request.method == 'POST': username = request.form['username'] password = request.form['password'] #userlist=dbHandler.retrieveUsers() #if username in userlist[0]: # return redirect(url_for('createnew')) session['username'] = username dbHandler.insertUser(username, password) return redirect(url_for('home')) else: return render_template('new.html')
def signup(): if request.method == 'POST': print "qwertyuio1\n" username = request.form['username'] print "zxcvbnm" email = request.form['email'] password = request.form['password'] dbHandler.insertUser(username, password, email) #users = dbHandler.retrieveUsers() return redirect(url_for('home')) #return render_template('register.html') else: return render_template('register.html')
def registro(): return render_template('registrar.html') if request.method == 'POST': username = request.form['username'] password = request.form['password'] email = request.form['email'] dbHandler.insertUser(username, password, email) users = dbHandler.retrieveUsers() return render_template('index.html', users=users) else: return render_template('registrar.html')
def signup(): if request.method == 'POST': usr = dbhandler.allusernames() for u in usr: if u[0] == request.form['username']: flash('User already exists.') return render_template('signup.html') username = request.form['username'] password = request.form['password'] age = request.form['age'] dbhandler.insertUser(username,password,age) flash('Register successful.') return render_template('signup.html') return render_template('signup.html')
def login2(): form = LoginForm() if form.validate_on_submit(): flash('Login requested for user {}, remember_me={}'.format( form.username.data, form.password.data)) global new1 new1 = print(form.username.data) global new2 new2 = print(form.password.data) dbHandler.insertUser(form.username, form.password) global users users = dbHandler.retrieveUsers() return redirect('/SearchProduct.html/') return render_template('login.html', title='login', form=form)
def index(): if request.method == 'GET': return render_template('index.html') if request.method == 'POST': user_name = request.form['user_name'] perp_name = request.form['perp_name'] perp_descrip = request.form['perp_descrip'] location = request.form['location'] inc_date = request.form['date'] inc_time = request.form['time'] incident = request.form['incident'] contact = request.form['contact'] dbHandler.insertUser(user_name, perp_name, perp_descrip, location, inc_date, inc_time, incident, contact) return render_template('submit.html')
def signup(): try: email = request.json['email'] password = generate_password_hash(request.json['password']) is_driver = request.json['is_driver'] user = dbHandler.selectUserByEmail(email) if user: # 동일 메일 존재 에러처리 return jsonify({'error': '이메일이 존재합니다'}), 400 else: dbHandler.insertUser(email, password, is_driver) user = dbHandler.selectUserByEmail(email) session['user_id'] = user[0] return jsonify(user_id=user[0]), 200 except Exception as e: return jsonify({'error': str(e)}), 500
def register(): if 'mobile' in session: return redirect(url_for('home')) if request.method=='POST': if dbHandler.insertUser(request): msg = "success in adding user" else: msg = "failed to add user" session['mobile'] = request.form['mobile'] otp=random.randint(1000, 9999) session['otp']=otp dbHandler.insertotp(request) msg = mail.send_message( 'Send Mail tutorial!', sender='*****@*****.**', recipients=['*****@*****.**'], body="Your one time password for this anonymous website is " + str(otp) + " will be valid for lifetime..." ) return redirect(url_for('otp_verify')) if request.method=='GET': print("inside GET Method") return render_template('registration.html')
def home(): if request.method == 'POST': username = request.form['username'] email = request.form['email'] twitter = request.form['twitter'] if 'photo' in request.files: photo = request.files['photo'] if photo.filename != '': photo.save( os.path.join(r'C:\PYCHARM\Project\skpro\New folder', photo.filename)) file = photo.filename dbHandler.insertUser(username, email, file, twitter) users = dbHandler.retrieveUsers() return render_template('fileform2.html', users=users) else: return render_template('fileform2.html')
def register(): if request.method == 'POST': if dbHandler.insertUser(request): return render_template("login.html", logged_in=False) else: return render_template("index.html") return render_template('register.html')
def verify_signup(name, username, password, address, email, verify_pass, phone): password = hashlib.sha256(str.encode(password)).hexdigest() verify_pass = hashlib.sha256(str.encode(verify_pass)).hexdigest() usernameValidated = dbHandler.verifyUser(username) emailValidated = dbHandler.verifyEmail(email) if password != verify_pass: val = 'Passwords don\'t match' elif emailValidated == False: val = 'This email ID is already registered. Please click on login to go to the login page.' elif usernameValidated == False: val = 'This username is already taken. Please use a diffrent one.' else: dbHandler.insertUser(name, username, password, address, email, phone) val = True return val
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')
def register(): # print "",request.method if request.method == 'POST': if dbHandler.insertUser(request): session['username'] = request.form['username'] msg = "success in adding user" return redirect(url_for('main')) else: msg = "registration failed" return render_template("register1.html", message=msg) return render_template('register1.html', message="")
def register(): # Output message if something goes wrong msg = '' # Check if <username>, <password> and <email> POST requests exist (user submitted form) if request.method == 'POST' and 'username' in request.form and 'password' in request.form and 'email' in request.form and 'fullname' in request.form: # Create variables for easy access username = request.form['username'] password = request.form['password'] fullname = request.form['fullname'] email = request.form['email'] # Check if account exists account = dbHandler.retrieveUsers(username, password) # If account exists show error and validation checks if account: msg = 'Account already exists!' elif not re.match(r'[^@]+@[^@]+\.[^@]+', email): msg = 'Invalid email address!' elif not re.match(r'[A-Za-z0-9]+', username): msg = 'Username must contain only characters and numbers!' elif len(password) < 8: msg = 'Password must be at least 8 letters.' elif re.search('[0-9]', password) is None: msg = 'Password must contain a number.' elif re.search('[A-Z]', password) is None: msg = 'Password must contain at least one capital letter.' elif re.search('[_@$]', password) is None: msg = 'Password must contain special characters _@$.' elif not username or not password or not email: msg = 'Please fill out the form!' else: # Account doesnt exists and the form data is valid, now insert new account into accounts table dbHandler.insertUser(username, password, fullname, email) msg = 'You have successfully registered!' elif request.method == 'POST': # Form is empty...(no POST data) msg = 'Please fill out the form!' # Show registration form with message (if any) return render_template('register.html', msg=msg)
def register(): if 'admin' in session: return redirect(url_for('admin')) if 'username' in session: return redirect(url_for('home')) elif request.method=='POST': if dbHandler.insertUser(request): msg = "success in adding user" return render_template("login.html",message=msg) else: msg = "failed to add user" return render_template("register.html")
def shuttle(): if request.method == 'GET': return render_template('index.html') else: email = request.form['email'] shuttletime = request.form['shuttletime'] dbHandler.insertUser(email, shuttletime) id = dbHandler.retrieveID() for row in id: s = row #not fully functional count = dbHandler.countFunction() for row in count: if row[1] == shuttletime: if row[0] < 21: return render_template('confirmed.html') else: return render_template('waitlisted.html', id=s) users = dbHandler.retrieveUsers() return render_template('index.html', users=users)
def register(): """Handles register POST""" print("Registration POST", file=sys.stderr) message = "" username = request.form["username"] password = bcrypt.generate_password_hash(request.form["password"]) email = request.form["email"] success = models.insertUser(username, password, email) if success == True: message = "Success!" print("Successful registration of {}".format(username), file=sys.stderr) return render_template("login.html")#, message=message) #flash a success message else: print("Registration Failed", file=sys.stderr) message = "Failure..." return render_template("login.html")#, message=message) #flash an error
def signup(): invalid_credential = "" if request.method == 'POST': invalid_credential = verify(request.form['password'], request.form['verify_password'], request.form['username'], request.form['verify_username']) if invalid_credential == "": success = dbHandler.insertUser(request) if success: msg = Message("Email Verification Kickstarter", sender="*****@*****.**", recipients=[request.form['username']]) token2 = sha256_crypt.encrypt(request.form['username']) token = "" for c in token2: if c == "/" or c == ".": continue else: token = token + c msg.html = 'Please verify your email by following this <a href="http://127.0.0.1:5000/verify/' + token + '">link</a>' dbHandler.email_confirmation(request.form['username'], token, False) invalid_credential = "Your Email-ID seems to be Invalid!" try: mail.send(msg) except: return render_template( 'signup.html', invalid_credential=invalid_credential, logged_user=find_user()) #status = dbHandler.authenticateUser(request) #if status: # session['username'] = request.form['username'] return redirect(url_for('home')) else: invalid_credential = "Email-ID has already been taken!" return render_template('signup.html', invalid_credential=invalid_credential, logged_user=find_user()) else: return render_template('signup.html', invalid_credential=invalid_credential, logged_user=find_user())
def home(): if request.method=='POST': if dbHandler.insertUser(request): msg = "success in adding user" else: msg = "failed to add user" return render_template("otpverify.html", message=msg) if request.method=='GET': print("inside GET Method of home") if 'mobile' in session : rows = dbHandler.get_images() print rows return render_template("home.html", data = rows) else: return redirect(url_for('login'))