def register(): if 'user_id' not in session: #check if user not yet login if request.method == 'POST': username = request.form.get("username") email = request.form.get("email") password = request.form.get("password") confirm = request.form.get("confirm") if password == confirm: if len(password) > 7: if EMAIL_REGEX.match(email): user = create_user(email, username, password) session['user_id'] = user.id session['username'] = user.email return redirect('/') else: flash("Please input correct email") return redirect('/register') else: flash("password minimum 8 char") return redirect('/register') else: flash("password must be same with confirm") return redirect('/register') else: return render_template('page_register.html') return redirect('/') #redirect if already login
def register(): fullname = request.form['html_fullname'] email = request.form['html_email'] password = request.form['html_password'] confirm = request.form['html_confirm'] is_valid = True is_valid = not is_blank('fullname', fullname) is_valid = not is_blank('email', email) is_valid = not is_blank('password', password) is_valid = not is_blank('confirm', confirm) if password != confirm: flash('password not match') is_valid = False if len(password) < 6: flash('pass to short') if not EMAIL_REGEX.match(email): flash('email is not right format') if is_valid: try: user = create_user(email, fullname, password) session['user_id'] = user.id session['name'] = user.name return redirect(url_for('index')) except: flash('email already registered dude') return redirect(url_for('authenticate', type='register'))
def register(): fullname = request.form['html_fullname'] username = request.form['html_username'] email = request.form['html_email'] password = request.form['html_password'] confirm = request.form['html_confirm'] is_valid = not is_blank('fullname', fullname) is_valid = not is_blank('email', email) is_valid = not is_blank('password', password) is_valid = not is_blank('confirm', confirm) if not EMAIL_REGEX.match(email): is_valid = False flash('invalid email format') if password != confirm: is_valid = False flash('password did not match') if(len(password) < 6): is_valid = False flash('password is too short') if is_valid: try: user = create_user(fullname, username, email, password) setup_web_session(user) return redirect(url_for('index')) except: flash('email already registered.') return redirect(url_for('register_form'))
def register(): fullname = request.form['html_fullname'] email = request.form['html_email'] password = request.form['html_password'] confirm = request.form['html_confirm'] is_valid = True is_valid = is_blank('Fullname', fullname) is_valid = is_blank('Email', email) is_valid = is_blank('Password', password) is_valid = is_blank('Confirm Password', confirm) if password != confirm: flash('Password do not match') is_valid = False if len(password) < 6: flash('Password have to be more than 6') is_valid = False if not EMAIL_REGEX.match(email): flash('Email format is wrong') is_valid = False if is_valid: try: user = create_user(email, fullname, password) session['name'] = user.name return redirect(url_for('index')) except: flash('Email alredy registered') return redirect(url_for('authenticate'))
def register(): is_valid = True for field in ['email', 'fullname', 'password']: if (len(request.form[field]) <= 0): flash('{} cannot be empty!'.format(field)) is_valid = False if (request.form['password'] != request.form['confirm']): flash('passwords do not match!') is_valid = False if (not is_valid): return redirect(url_for('register_form')) user = None try: hashed_pw = bcrypt.hashpw(request.form['password'].encode('UTF-8'), bcrypt.gensalt()) user = db.create_user(request.form['email'], request.form['fullname'], hashed_pw) except sqlalchemy.exc.IntegrityError: flash('email address already registered!') except Exception as ex: flash('internal error: {}'.format(ex)) if (user is None): return redirect(url_for('register_form')) session.clear() session['user_id'] = user.id session['fullname'] = user.fullname return redirect(url_for('home'))
def register(): email = request.form['html_email'] username = request.form['html_username'] password = request.form['html_password'] confirm = request.form['html_confirm'] is_valid = True if is_empty('email', request.form): is_valid = False if is_empty('username', request.form): is_valid = False if is_empty('password', request.form): is_valid = False if password != confirm: flash('passwords do not match') is_valid = False if is_valid == False: return redirect(url_for('authenticate')) user = create_user(email, username, password) session['user_id'] = user.id session['username'] = user.username return redirect(url_for('index'))
def register(): fullname = request.form['html_fullname'] email = request.form['html_email'] password = request.form['html_password'] confirm = request.form['html_confirm'] sys.stdout.flush() is_valid = not is_blank('name', fullname) is_valid = not is_blank('email', email) is_valid = not is_blank('password', password) is_valid = not is_blank('confirm', confirm) if password != confirm: flash('Passwords do not match.') is_valid = False if len(password) < 6: flash('Password should be longer than 6 characters.') is_valid = False if not EMAIL_REGEX.match(email): flash('Invalid email.') is_valid = False if is_valid: try: encoded = password.encode('UTF-8') encrypted = bcrypt.hashpw(encoded, bcrypt.gensalt()) user = create_user(email, fullname, encrypted) session['name'] = user.name session['email'] = user.email return redirect(url_for('index')) except: flash('E-mail already regsistered.') return redirect(url_for('authenticate'))
def register_process(): name = request.form['html_name'] email = request.form['html_email'] password = request.form['html_password'] confirm = request.form['html_confirm'] result = db.create_user(name, email, password, confirm) if type(result) == User: setup_web_session(result) return redirect(url_for('index')) else: for err in result: flash(err) return redirect(url_for('register_form'))
def register(): name = request.form['html_fullname'] email = request.form['html_email'] password = request.form['html_password'] confirm = request.form['html_confirm'] user = create_user(name, email, password, confirm) if user: session['user_id'] = user.id session['name'] = user.name return redirect(url_for('index')) else: for messages in user: flash(messages) return redirect(url_for('authenticate'))
def register(): email = request.form['html_email'] username = request.form['html_username'] password = request.form['html_password'] confirm = request.form['html_confirm'] is_valid = True if not EMAIL_REGEX.match(email): flash("invalid email address") is_valid = False if is_empty('email', request.form): is_valid = False if is_empty('username', request.form): is_valid = False if is_empty('password', request.form): is_valid = False if password != confirm: flash('passwords do not match') is_valid = False if is_valid == False: return redirect(url_for('authenticate')) try: encoded_utf8 = password.encode('UTF-8') encrypted = bcrypt.hashpw(encoded_utf8, bcrypt.gensalt()) user = create_user(email, username, encrypted) session['user_id'] = user.id session['username'] = user.name except: flash('user already exists') return redirect(url_for('authenticate')) return redirect(url_for('index'))
def register_authenticate(): server_email = request.form['html_email'] server_username = request.form['html_username'] server_password = request.form['html_password'] server_confirm = request.form['html_confirm'] is_valid = True if not EMAIL_REGEX.match(server_email): flash('invalid e-mail address') is_valid = False if server_password != server_confirm: flash('passwords are not the same') is_valid = False if is_empty('email', request.form): is_valid = False if is_empty('username', request.form): is_valid = False if is_empty('password', request.form): is_valid = False if not is_valid: return redirect(url_for('register')) encoded_utf8 = server_password.encode('UTF-8') encrypted = bcrypt.hashpw(encoded_utf8, bcrypt.gensalt()) user = db.create_user(server_email, server_username, encrypted) session['user_id'] = user.id session['username'] = user.name return redirect(url_for('index'))
def register(): if request.method == 'POST': fullname = request.form['html_fullname'] email = request.form['html_email'] password = request.form['html_password'] confirm = request.form['html_confirm'] is_valid = True is_valid = not is_blank('Fullname', fullname) is_valid = not is_blank('Email', email) is_valid = not is_blank('Password', password) is_valid = not is_blank('Confirm Password', confirm) if password != confirm: flash('Password do not match') is_valid = False if len(password) < 6: flash('Password have to be more than 6') is_valid = False if not EMAIL_REGEX.match(email): flash('Email format is wrong') is_valid = False if is_valid: try: encoded = password.encode('UTF-8') encrypted_password = bcrypt.hashpw(encoded, bcrypt.gensalt()) user = create_user(email, fullname, encrypted_password) setup_web_session(user) return redirect(url_for('index')) except: raise flash('Email alredy registered') return redirect(url_for('register')) else: return render_template('register.html')
def register(): is_valid = True for field in ['html_email', 'html_username', 'html_password']: if (len(request.form[field]) <= 0): flash('{} cannot be empty!'.format(field[5:])) is_valid = False if (request.form['html_password'] != request.form['html_confirm']): flash('passwords do not match!') is_valid = False if (not is_valid): return redirect('authenticate') user = None try: user = create_user(request.form['html_email'], request.form['html_username'], request.form['html_password']) except sqlalchemy.exc.IntegrityError: pass except Exception as ex: print(ex) if (user is None): flash('email address already registered!') return redirect(url_for('authenticate')) session['user_id'] = user.id session['username'] = user.name return redirect(url_for('index'))
def register(): print('--------------------------------------------------') print(request.method) if request.method == 'POST': fullname = request.form['html_fullname'] email = request.form['html_email'] password = request.form['html_password'] confirm = request.form['html_confirm'] is_valid = True is_valid = not is_blank('Fullname', fullname) is_valid = not is_blank('Email', email) is_valid = not is_blank('Password', password) is_valid = not is_blank('Confirm Password', confirm) if password != confirm: flash('Password do not match') is_valid = False if len(password) < 6: flash('Password have to be more than 6') is_valid = False if not EMAIL_REGEX.match(email): flash('Email format is wrong') is_valid = False if is_valid: try: user = create_user(email, fullname, password) setup_web_session(user) return redirect(url_for('index')) except: flash('Email alredy registered') return redirect(url_for('register')) else: return render_template('user/register.html')