def signup(): form = RegistrationForm() if form.validate_on_submit(): proposed_username = name_generator_STRING() proposed_password = passcode_generator_INT() if proposed_username in fake_name_db_ARRAY: proposed_username = proposed_username + ("%d" % randbelow(999)) fake_name_db_ARRAY.append(proposed_username) fake_logger_ARRAY.append({proposed_username, proposed_password}) print(fake_logger_ARRAY) userToBeAdded = UserAccount(username=name_generator_STRING(), mobile=form.mobile.data, email=form.email.data, passcode="%d" % proposed_password, ip_address=request.environ['REMOTE_ADDR']) try: session.add(userToBeAdded) session.commit() except: session.rollback() flash('This account already exists, please login') return render_template('signup.html', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): user = User(username=form.username.data, password=form.password.data) db.session.add(user) db.session.commit() flash("thank you for registering") return redirect(url_for('login')) return render_template('register.html', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): user = User(True, form.username.data, form.email.data) user.set_password(form.password.data) user.add_user() return user.get_user(form.username.data) flash_errors(form.errors.items()) return render_template('register.html', title='Register', form=form)
def signup_post(): form = RegistrationForm() if form.validate(): email = request.form.get('email') name = request.form.get('name') password = request.form.get('password') print(email) print(name) print(password) new_user = User(email=email, name=name, password=generate_password_hash(password, method='sha256')) print(new_user) db.session.add(new_user) db.session.commit() flash('Thanks for registering') return redirect(url_for('auth.login')) return render_template('signup.html', form=form, error=form.errors)
def registration(): if request.method == 'GET': form = RegistrationForm() return render_template('registration.html', form=form, error=form.errors) else: form = RegistrationForm() if form.validate_on_submit(): try: if User.query.filter_by(email=form.email.data).first(): message_body = 'User already exists' message_title = 'Oops!' return render_template('message.html', message_title=message_title, message_body=message_body) else: new_user = User(email=form.email.data, first_name=form.first_name.data, surname=form.surname.data, password_hash=generate_password_hash( form.password.data)) send_confirmation_email(new_user.email) db.session.add(new_user) db.session.commit() except (ValueError, TypeError): message_body = 'Registration failed' message_title = 'Error!' return render_template('message.html', message_title=message_title, message_body=message_body) else: return render_template('registration.html', form=form, error=form.errors) message_body = 'The registration was successful.' message_title = 'Success!' return render_template('message.html', message_title=message_title, message_body=message_body)
def registration_form_invalid(): """ Returns registration form containing invalid data """ form = RegistrationForm( email=g.person.name() + '.' + g.person.surname() + '@gmail.com', first_name=g.person.name(), surname=g.person.surname(), password=g.cryptographic.hash(), confirm_pass=g.cryptographic.hash(), ) yield form
def registration_form_registered_user(db_tieto_user): """ Returns registration form containing data of already registered user. """ form = RegistrationForm( email=User.query.filter_by(id=db_tieto_user[0].id).first().email, first_name=User.query.filter_by( id=db_tieto_user[0].id).first().first_name, surname=User.query.filter_by(id=db_tieto_user[0].id).first().surname, password=db_tieto_user[1], confirm_pass=db_tieto_user[1], ) yield form
def registration_form(): """ Returns registration form containing valid data. """ new_password = g.person.password(length=8) form = RegistrationForm( email=g.person.name() + '.' + g.person.surname() + '@tieto.com', first_name=g.person.name(), surname=g.person.surname(), password=new_password, confirm_pass=new_password, ) yield form
def signup_post(): try: form = RegistrationForm() if form.validate(): email = request.form.get('email') name = request.form.get('name') password = request.form.get('password') new_user = User(email=email, name=name, password=generate_password_hash(password, method='sha256'), valid=False, membership="None", valid_till="None", is_admin=False) db.session.add(new_user) db.session.commit() flash('Please Log in below') return redirect(url_for('main.profile')) except Exception: flash('Email already registered') render_template('signup.html', form=form, error=form.errors) return render_template('signup.html', form=form, error=form.errors)
def register(): form = RegistrationForm() if current_user.is_authenticated: flash( f'You are already loggedin as {current_user.username}. Logout to Register a new User', 'info') return redirect(url_for('home', title="Home", _external=True)) if request.method == "POST": if not User.query.filter_by(username=form.username.data).first(): if not User.query.filter_by(email=form.email.data).first(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(username=form.username.data, email=form.email.data, password=hashed_password) db.session.add(user) db.session.commit() flash( f'Account successfully created for the email: { user.email.data }', 'success') return redirect( url_for('login', title='Login', form=form, _external=True)) else: flash( f'The Email { form.email.data } is already taken. Please use a different email id.', 'danger') return redirect( url_for('register', title='Login', form=form, _external=True)) else: flash( f'The Username {form.username.data } is already taken. Please use a different username.', 'danger') return redirect( url_for('register', title="Register", form=form, _external=True)) else: return render_template('register.html', title="Register", form=form)
def register(): f = RegistrationForm(request.form) if request.method == "POST" and f.validate_on_submit(): return register_user(f.username.data, f.password.data) else: return render_template('register.html', form=f)
def register(): form = RegistrationForm() if form.validate_on_submit(): flash(f'Account created for {form.username.data}!', 'success') return redirect(url_for('home')) return render_template('register.html', title='Register', form=form)