def register(): form = RegistrationForm() if form.validate_on_submit(): flash(f'Account created successfully for {form.username.data}', category='success') return redirect(url_for('home')) return render_template('register.html', title='Register', form=form)
def register(): form = RegistrationForm() # this is POST method if form.validate_on_submit(): # f-string lets you pass variables (python 3.6 and above) flash(f'Account created for {form.username.data}!', 'success') return redirect(url_for('home')) return render_template('register.html', title='Register', form=form)
def submit(): form = RegistrationForm() if form.validate_on_submit(): planet = Planet(name=form.name.data, size=form.size.data, distance=form.distance.data, ordinality=form.ordinality.data, description=form.description.data) db.session.add(planet) db.session.commit() flash('Planet added', 'success') return redirect(url_for('home')) return render_template('submit.html', title='submit', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('public.index')) form = RegistrationForm() if form.validate_on_submit(): RegistrationForm.register(form) flash(f'Registration Successful.') return redirect(url_for('auth.login')) return render_template('register.html', title='Register', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) 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("Account registerd sucessfully. You can now login", 'success') return redirect(url_for('login')) return render_template("register.html", title="Register", form=form)
def sign(): form = RegistrationForm() if form.validate_on_submit(): newEmail = Email(email=form.email.data) db.session.add(newEmail) db.session.commit() flash("Thanks for registering") return render_template("home.html") return render_template("sign.html", form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') newUser = User(username=form.username.data, email=form.email.data, password=hashed_password) db.session.add(newUser) db.session.commit() flash(f'Your account has been created! You can login now', 'success') return redirect(url_for('home')) return render_template('register.html', title='Register', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): 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('Tilisi on luotu! Nyt voit kirjautua sisään!', 'success') return redirect(url_for('login')) return render_template('register.html', title='Rekisteröityminen', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): # hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8') user = User(username=form.username.data, email=form.email.data, password=form.password.data) db.session.add(user) db.session.commit() flash('Your account has been created! You are now able to log in', 'success') return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): hashed_pw = bcrypt.generate_password_hash( form.password.data).decode('utf-8') new_user = User(username=form.username.data, email=form.email.data, password=hashed_pw) db.session.add(new_user) db.session.commit() flash(f"Account with email: {form.email.data} is created.", 'success') return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(username=form.username.data, password=hashed_password) db.session.add(user) db.session.commit() flash("Your account has been created, You can now login!", "success") return redirect(url_for('login')) return render_template("register.html", form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() # Bei erfolgreicher Registration -> success-alert via Bootstrap if form.validate_on_submit(): 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'Dein Account wurde erfolgreich registriert. Jetzt anmelden!', 'success') return redirect(url_for('login')) return render_template('registration.html', title='Registration', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for("home")) form = RegistrationForm() if form.validate_on_submit(): hashed_pw = bcrypt.generate_password_hash( form.password.data).decode("utf-8") user = User(username=form.username.data, password=hashed_pw) db.session.add(user) db.session.commit() flash('Account Created', "success") return redirect(url_for('login')) return render_template("register.html", form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): user = User(username=form.username.data, email=form.email.data, password=form.password.data) db.session.add(user) db.session.commit() flash(f'Account created for {form.username.data}!', 'success') return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): hash_pass = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(username=form.username.data, email=form.email.data, password=hash_pass) db.session.add(user) db.session.commit() flash('Account Have Been Created!, You Are Now Able To Login', 'success') return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)
def home(): form = RegistrationForm() if form.validate_on_submit(): name = form.first_name.data + form.last_name.data email = form.email.data message = form.message.data new_commit = Message(name=name, email=email, message=message) db.session.add(new_commit) db.session.commit() flash("mesage delivered", 'success') return render_template("home.html", form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash(form.password.data) new_user = User(username=form.username.data, email=form.email.data, password=hashed_password) db.session.add(new_user) db.session.commit() flash(f"Account created for {form.username.data}! You can now Log In.", 'success') return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)
def signup(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(email=form.email.data, full_name=form.full_name.data, username=form.username.data, password=hashed_password) db.session.add(user) db.session.commit() return redirect(url_for('login')) return render_template('signup.html', form=form)
def signup(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): 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('Account created for %s!' % form.username.data, 'success') return redirect(url_for('login')) return render_template('signup.html', title='Sign Up', form=form)
def register(): posts = recentPost() image_file = url_for('static', filename='anime_thumbnail/downloads/') suggestedAnime = SuggestedContent(current_user) if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): admin = 'n' 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, admin=admin) db.session.add(user) db.session.commit() flash('Your account has been created!', 'success') return redirect(url_for('login')) return render_template('register.html', title='Register', form=form, suggestedAnime=suggestedAnime, image_file=image_file, posts=posts)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): user = User(username=form.username.data, email=form.email.data) user.set_password(password=form.password.data) user.save(user) token = token_activation(user.username, user.email) register_mail_activate(user, token) flash( 'An email has been sent with instructions to activate your account.', 'info') return render_template('register.html', title='Register', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('index')) form = RegistrationForm() if form.validate_on_submit(): hash_pw = bcrypt.generate_password_hash( form.password.data).decode('utf-8') new_user = User(username=form.username.data, email=form.email.data, password=hash_pw) role = Role(name='admin') new_user.roles.append(role) db.session.add(new_user) db.session.commit() flash('Congrats! Your account been created successfully', 'info') return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) #calls RegistrationForm() class from forms.py form = RegistrationForm() #when form is submitted passes requirements, an account is created #and the user is rerouted to home page. A message will appear to inform user #the account was created. if form.validate_on_submit(): #hashing password hashed_pw = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(username=form.username.data, email=form.email.data, password=hashed_pw) db.session.add(user) db.session.commit() #end hashing flash(f'Account created. Please Log into your account', 'Success') return redirect(url_for('login')) return render_template('register.html', form=form)
def registration(): login_form = LoginForm() reg_form = RegistrationForm() modal_attr = "" if login_form.submit2.data: if login_form.validate_on_submit(): user = find_by_email_with_pass(login_form.email.data) if user and bcrypt.check_password_hash(user["password"], login_form.password.data): session["user"] = login_form.email.data session.permanent = True return redirect(url_for('home')) else: modal_attr = "myModal" else: modal_attr = "myModal" if reg_form.submit1.data: if reg_form.validate_on_submit( ) and request.form.get('select') != 'not selected': hashed_password = bcrypt.generate_password_hash( reg_form.password.data).decode('utf-8') register(reg_form.username.data, reg_form.first_name.data, reg_form.last_name.data, reg_form.email.data, hashed_password, reg_form.phone_number.data, request.form.get('select')) session["user"] = reg_form.email.data session.permanent = True flash(f'Fiók létrehozva !', 'success') return redirect(url_for('home')) elif request.method == 'POST' and request.form.get( 'select') == 'not selected': flash(f'Válassz a listából !', 'danger') print(reg_form.submit1.data, 'reg') return render_template('reg.html', reg_form=reg_form, login_form=login_form, modal_attr=modal_attr)
def register(): # register 페이지에 RegistrationForm() 클래스가 작동하게 만들어줌 if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() # 여기의 폼은 forms.py에서 선언한 Regist~~form이고, if form.validate_on_submit(): # 만약 제출한 폼이 유효성 검사에 통과했다면 아래의 코드를 실행한다. # form에 맞게 입력한 데이터를 User 클래스를 생성해서 데이터에 입력해줍니다. # 단 비밀번호는 해시화해서 넣어줍니다. 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() # db에 user 추가 후 커밋 flash(f'Your account has been created! You are now able to log in', 'success') return redirect(url_for('home')) # 유저 등록이 성공적으로 될시에 위와같은 일회성 문구를 전송하고, 홈페이지로 돌아갑니다. return render_template('register.html', title='Register', form=form)
def register(): try: if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): if str(form.tel_nr.data).isdigit()==True: tel = User.query.filter_by(tel_nr=form.tel_nr.data).first() if tel == None: hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8') user = User(username=form.username.data, email=form.email.data,tel_nr=form.tel_nr.data, age=form.age.data, password=hashed_password) db.session.add(user) db.session.commit() user1 = User.query.filter_by(username=form.username.data).first() info = Info(author=user1, created=now_date) db.session.add(info) db.session.commit() flash('Towje konto zostało stworzone!', 'success') return redirect(url_for('login')) else: flash("Numer telefonu jest już zajęty", "danger") return redirect(url_for('register')) else: flash("Numer telefonu nie może zawierać znaków", "danger") return redirect(url_for('register')) return render_template('register.html', title='Rejestracja', form=form) except Exception as e: print("Error at ", e) log(e, request.path, False) return render_template('error_page.html', error = type(e))
def register(): if current_user.is_authenticated: return redirect(url_for('index')) form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8') utente = Utente(email=form.email.data, nome=form.nome.data, cognome=form.cognome.data, password=hashed_password, ruolo=form.ruolo.data, comune_volontariato=form.comune_volontariato.data, orario_inizio='00:00:00', orario_fine='00:00:00') db.session.add(utente) db.session.commit() utente_id = Utente.query.filter_by(email=utente.email).first().id giorni_disponibili = Giorni_Disponibili(utente_id=utente_id, lunedi=0, martedi=0, mercoledi=0, giovedi=0, venerdi=0, sabato=0, domenica=0) db.session.add(giorni_disponibili) db.session.commit() flash('Account creato! Puoi ora effettuare il login', 'success') return redirect(url_for('login')) return render_template("register.html", title="Register", form=form)