def register(): form = RegisterForm() if request.args.get('storecode'): session['temp_storecode'] = request.args.get('storecode') # store storecode in temp_storecode session if form.validate_on_submit(): code = str(uuid.uuid4()) hash_pwd = generate_password_hash(form.password.data) user = User(username=form.username.data, password=hash_pwd, email=form.email.data, change_configuration={ "new_email": form.email.data.lower(), "confirmation_code": code }, email_confirmed=True) if session.get('temp_storecode'): body_html = render_template( 'mail/user/confirm.html', user=user, storecode=session.get('temp_storecode')) body_text = render_template( 'mail/user/confirm.txt', user=user, storecode=session.get('temp_storecode')) else: body_html = render_template('mail/user/confirm_n.html', user=user) body_text = render_template('mail/user/confirm_n.txt', user=user) email(user.email.lower(), "Email confirmation", body_html, body_text) user.save() return redirect( url_for('user_app.awaiting', user_email=form.email.data.lower())) return render_template('user/register.html', form=form)
def register(): form = RegisterForm(request.form) if form.validate_on_submit(): usr = insert_user(name=form.name.data, surname=form.surname.data, email=form.email.data, password=form.password.data, dateofbirth=form.dateofbirth.data, university=form.university.data, course=form.course.data) if isinstance(usr, (int, long)): return redirect(url_for("user.register")) token = generate_confirmation_token(usr.email) confirm_url = url_for('user.confirm_email', token=token, _external=True) html = render_template('user/activate.html', confirm_url=confirm_url) subject = "Please confirm your email" send_email(usr.email, subject, html) login_user(usr) flash('A confirmation email has been sent via email.', 'success') return redirect(url_for("main.home")) return render_template('user/register.html', form=form)
def register(): form = RegisterForm() if form.validate_on_submit(): # ie passes validation # generate a salt (password generation key) salt = bcrypt.gensalt() # encrypt the password using the salt key hashed_password = bcrypt.hashpw(form.password.data, salt) # Create a unique identifier to store in the change_configuration field code = str(uuid.uuid4()) # Create the user object user = User(username=form.username.data, password=hashed_password, email=form.email.data, first_name=form.first_name.data, last_name=form.last_name.data, bio=form.bio.data, change_configuration={ "new_email": form.email.data.lower(), "confirmation_code": code }) # Email verification to the user body_html = render_template('mail/user/register.html', user=user) body_text = render_template('mail/user/register.txt', user=user) email(user.email, 'Welcome to Flaskbook', body_html, body_text) # save the user to the database user.save() return 'User registered' return render_template('user/register.html', form=form)
def register(): form = RegisterForm() message = None if form.validate_on_submit(): salt = bcrypt.gensalt() code = str(uuid.uuid4().hex) hashed_password = bcrypt.hashpw(form.password.data, salt) user = User(username=form.username.data, password=hashed_password, email=form.email.data, first_name=form.first_name.data, last_name=form.last_name.data, bio=form.bio.data, change_configuration={ "new_email": form.email.data.lower(), "confirmation_code": code }) user.save_database() # send email html_body = render_template('mail/user/register.html', user=user) html_text = render_template('mail/user/register.txt', user=user) email(user.change_configuration['new_email'], "Confirm your email", html_body, html_text) message = "Please Check you email to complete registration." return render_template('user/register.html', form=form, message=message) return render_template('user/register.html', form=form, message=message)
def register(): form = RegisterForm() if form.validate_on_submit(): # salt = bcrypt.gensalt() # hashed_password = bcrypt.hashpw(form.password.data, salt) code = str(uuid.uuid4()) password64 = maxx_encode(form.password.data) user = User(username=form.username.data, password=password64, email=form.email.data, first_name=form.first_name.data, last_name=form.last_name.data, change_configuration={ "new_email": form.email.data.lower(), "confirmation_code": code }) # email the user body_html = render_template('mail/user/register.html', user=user) body_text = render_template('mail/user/register.txt', user=user) email(user.email, "Welcome to White History Week", body_html, body_text) user.save() return redirect(url_for('home_app.home')) return render_template('user/register.html', form=form)
def register(): form = RegisterForm() if form.validate_on_submit(): salt = bcrypt.gensalt() hashed_password = bcrypt.hashpw(form.password.data, salt) code = str(uuid.uuid4()) user = User( username=form.username.data, password=hashed_password, email=form.email.data, first_name=form.first_name.data, last_name=form.last_name.data, change_configuration={ "new_email": form.email.data.lower(), "confirmation_code": code } ) # email the user body_html = render_template('mail/user/register.html', user=user) body_text = render_template('mail/user/register.txt', user=user) email(user.email, "Welcome to Flaskbook", body_html, body_text) user.save() return "User registered" return render_template('user/register.html', form=form)
def register(): form = RegisterForm() if form.validate_on_submit(): salt = bcrypt.gensalt() hashed_password = bcrypt.hashpw(form.password.data, salt) code = str(uuid.uuid4()) user = User( username=form.username.data, password=hashed_password, email=form.email.data, first_name=form.first_name.data, last_name=form.last_name.data, change_configuration={ "new_email": form.email.data.lower(), "confirmation_code": code } ) # email the user body_html = render_template('mail/user/register.html', user=user) body_text = render_template('mail/user/register.txt', user=user) email(user.email, "Welcome to Flaskbook", body_html, body_text) user.save() return redirect(url_for('home_app.home')) return render_template('user/register.html', form=form)
def register(): form=RegisterForm() if form.validate_on_submit(): salt=bcrypt.gensalt(10) hashed_password=bcrypt.hashpw(form.password.data,salt) user = User(username=form.username.data,password=hashed_password,email=form.email.data,first_name=form.first_name.data,last_name=form.last_name.data) user.save() return 'User registered' return render_template('user/register.html',form=form)
def register(): form = RegisterForm() if form.validate_on_submit(): user = User(email=form.email.data, username=form.username.data, password=form.password.data) db.session.add(user) db.session.commit() flash('Register Success!') return redirect(url_for('login')) return render_template('user/register.html', form=form)
def register(): form = RegisterForm() if form.validate_on_submit(): fullname = form.fullname.data username = form.username.data password = form.password.data email = form.email.data is_admin = False user = User(fullname, username, password, email, is_admin) db.session.add(user) db.session.commit() return redirect(url_for('dashboard/admin')) return render_template('user/register.html', form=form)
def register(): form = RegisterForm() if form.validate_on_submit(): user = User( username=form.username.data, password=AuthUtils.hash_password(plaintext_pw=form.password.data), email=form.email.data, first_name=form.first_name.data, last_name=form.last_name.data, ) user.save() return "User Successfully Registered (TODO make this page)" return render_template('user/register.html', form=form)
def register(): if request.method == "POST": flag = 1 else: flag = 0 if current_user.is_authenticated: print("Da log in roi ") return redirect(url_for("home_app.home")) form = home_form() register_form = RegisterForm() if register_form.validate_on_submit(): print("=======> ok ") salt = bcrypt.gensalt() hashed_password = bcrypt.hashpw( register_form.password.data.encode("utf-8"), salt) code = str(uuid.uuid4()) user = User(username=register_form.username.data, password=hashed_password, email=register_form.email.data, first_name=register_form.first_name.data, last_name=register_form.last_name.data, change_configuration={ "new_email": register_form.email.data.lower(), "confirmation_code": code }) body_html = render_template('mail/user/register.html', user=user) body_text = render_template('mail/user/register.txt', user=user) msg = Message("Wellcome to Whatever.vn", sender="*****@*****.**", recipients=[user.email]) msg.text = body_text msg.html = body_html resp = mail.send(msg) user.save() flash( "Successful account creation ! You need to activate by clicking on the link sent to the email" ) #print(user._data) else: print(register_form.errors.keys()) for i, val in register_form.errors.items(): print(i, " || ", val) print(register_form.errors.keys()) print(flag) return render_template("user/register.html", form=form, error=None, register_form=register_form, flag=flag)
def register(): form = RegisterForm() if request.method == 'POST': if form.validate_on_submit(): salt = bcrypt.gensalt() user = User(username=form.username.data, password=bcrypt.hashpw(form.password.data, salt)).save() return redirect(url_for('user_app.login')) return render_template('user/register.html', form=form)
def register(): form = RegisterForm() if form.validate_on_submit(): hashed_password = bcrypt.hashpw(form.password.data.encode('utf8'), bcrypt.gensalt()) user = User(first_name=form.first_name.data, last_name=form.last_name.data, email=form.email.data, username=form.username.data, password=hashed_password) db.session.add(user) db.session.commit() return 'User Registered' return render_template('user/register.html', form=form)
def register(): form = RegisterForm() if form.validate_on_submit(): salt = bcrypt.gensalt() hashed_password = bcrypt.hashpw(form.password.data.encode('utf-8'), salt) user = User( username=form.username.data, password=hashed_password, email=form.email.data, first_name=form.first_name.data, last_name=form.last_name.data, ) user.save() return redirect(url_for('user_app.login')) return render_template('user/register.html', form=form)
def register(): """Register view.""" form = RegisterForm() if form.validate_on_submit(): flash("Username registered.", "success") user.create_user( first_name=form.first_name.data, second_name=form.second_name.data, phone=form.phone.data, role=form.role.data, username=form.username.data, password=form.password.data, email=form.email.data ) return redirect(url_for('index')) return render_template('user/register.html', form=form)
def register(): if get_current_user().is_anonymous(): register_form = RegisterForm() if register_form.validate_on_submit(): create_user( first_name=register_form.first_name.data, last_name=register_form.last_name.data, username=register_form.username.data, email=register_form.email.data, password=generate_password_hash(register_form.password.data) ) return redirect(url_for('login')) else: return render_template('register.html', register_form=register_form ) else: flash("You are already an user.") return redirect(url_for('dashboard'))
def register(): form = RegisterForm() if form.validate_on_submit(): salt = bcrypt.gensalt() hashed_password = bcrypt.hashpw(form.password.data, salt) user = User(form.fullname.data, form.email.data, form.username.data, hashed_password) try: db.session.add(user) db.session.commit() flash('User created successfully!', 'success') flash( 'Please contact the admin to be be approve your account to login!', 'success') flash('Admin info is found in the Contact tab!', 'success') return redirect(url_for('login')) except SQLAlchemyError as e: db.session.rollback() flash('User already exists!', 'error') return render_template('user/register.html', form=form)
def register(): # Registration form in login view if not flask_login.current_user.is_authenticated(): reg_form = RegisterForm() if reg_form.validate_on_submit(): create_user( first_name=reg_form.first_name.data, last_name=reg_form.last_name.data, username=reg_form.username.data, password=generate_password_hash(reg_form.password.data), university_email=reg_form.university_email.data, ) flash("User created successfully!", "success") token = generate_confirmation_token(reg_form.university_email.data, secret_key=app.secret_key) html = render_template( 'email/verifyNewAccount/verification.html', token=token, name=reg_form.first_name.data, ) subject = "Confirm email and activate your account!" msg = Message(subject, recipients=[reg_form.university_email.data], html=html, sender=app.config['MAIL_SENDER']) MAIL.send(msg) flash("An email confirmation has been sent to your email.", "success") return redirect(url_for('login')) for errors in reg_form.errors.items(): for error in errors[1]: flash("{}".format(error)) return redirect(url_for('login')) flash("You are logged in.") return redirect(url_for('dashboard'))
def register(): form = RegisterForm() if form.validate_on_submit(): hash_and_salted_password = generate_password_hash( request.form.get('password1'), method='pbkdf2:sha256', salt_length=8) if User.query.filter_by(email=request.form.get("email")).first(): flash("email already registered") return redirect(url_for("login")) new_user = User(email=request.form.get("email"), user_name=request.form.get("user_name"), password_hash=hash_and_salted_password) db.session.add(new_user) db.session.commit() login_user(new_user) return redirect(url_for("login")) if form.errors != {}: for err_msg in form.errors.values(): flash(f"there was an error creating a user {err_msg}", category="danger") return render_template("register.html", form=form)