def register(): if not current_user.is_authenticated: form = RegisterForm() if form.validate_on_submit(): name = form.name.data email = form.email.data password = form.password.data confirm_password = form.confirm_password.data query = database.filter_by('users', {"email": email}) if not query: if password == confirm_password: user = User(name, email, password, "standard", SEARCH_LIMIT) database.create("users", user) flash('Conta registrada com sucesso!', 'success') return redirect(url_for("login")) else: flash('A senha de confirmação está incorreta!', 'danger') return render_template('register.html', form=form) else: flash('Email já cadastrado!', 'danger') return render_template('register.html', form=form) return render_template('register.html', form=form) else: flash('Você já está logado no sistema!', 'info') return redirect(url_for("index"))
def register(): form = RegisterForm() if form.validate_on_submit(): user = User(form.username.data, form.password.data) db.session.add(user) db.session.commit() return render_template('register.html', form=form)
def register(): """ Página para regitrar novos usuarios :return: """ register_form = RegisterForm() if register_form.validate_on_submit(): user = User.query.filter_by( username=register_form.username.data).first() email = User.query.filter_by( email=register_form.email.data).first() if user: flash("Usuário inválido") elif email: flash("Email inválido") else: i = User(str(register_form.username.data), str(register_form.password.data), str(register_form.name.data), str(register_form.email.data)) db.session.add(i) db.session.commit() return redirect(url_for('login')) return render_template('register.html', register_form=register_form)
def sign_up(): form = RegisterForm() created = None exist_email = None exist_username = None if form.validate_on_submit(): if request.method == "POST": username = form.username.data password = form.password.data email = form.email.data flag = dbo.User.create(username, password, email) if type(flag) == bool and flag == True: created = True print("Cadastrado com sucesso!") return redirect(url_for('login')) else: created = False print("Ocorreu um erro. {}".format(flag)) if 'email' in flag: exist_email = True if 'username' in flag: exist_username = True return render_template('sign_up.html', form=form, exist_email=exist_email, exist_username=exist_username, created=created)
def register(): form = RegisterForm() if form.validate_on_submit(): i = User(username=form.username.data, name=form.name.data, email=form.email.data, password=form.password.data) db.session.add(i) db.session.commit() flash("Olá %s Faça Login" % (form.name.data) ) return redirect( url_for("login") ) return render_template("register.html", form = form)
def register(): form = RegisterForm() if form.validate_on_submit(): user = User(username=form.username.data, email=form.email.data, name=form.name.data) user.generate_password(form.password.data) db.session.add(user) db.session.commit() flash("User registered successfully") return redirect(url_for("login")) return render_template("register.html", form=form)
def register(): rf = RegisterForm() seeID = requests.get("http://localhost:3000/api/User").json() nextID = int(seeID[len(seeID) - 1].get('userId')) + 1 if rf.validate_on_submit(): newUsr = jsonify(userID=str(nextID), firstName=rf.firstName.data, lastName=rf.lastName.data) print(newUsr) flash("Seu ID é : " + str(nextID)) flash("Bem vindo, " + rf.firstName.data + " " + rf.lastName.data) return render_template('register.html', rf=rf)
def register(): register_form = RegisterForm() if register_form.validate_on_submit(): instance = User(register_form.username.data, register_form.email.data, register_form.password.data) db.session.add(instance) db.session.commit() return redirect(url_for('login')) else: print(register_form.errors) return render_template("register.html", form=register_form)
def create_user(): form = RegisterForm() if form.validate_on_submit(): print(form.username) user = User(form.username.data, form.password.data, form.name.data, form.email.data) db.session.add(user) db.session.commit() flash('registered successful!') return redirect(url_for('login')) if form.errors: flash('Error, try again!') print(form.errors) return render_template('register.html', form=form)
def register(): rf = RegisterForm() if rf.validate_on_submit(): if rf.password.data == rf.password2.data: pw_hash = bcrypt.generate_password_hash( rf.password.data).decode("utf-8") user = User(rf.username.data, pw_hash) db.session.add(user) db.session.commit() flash('Registrado !') return redirect(url_for('login')) else: flash('Senhas não correspondem !') return render_template('register.html', rf=rf)
def register(): form = RegisterForm() if form.validate_on_submit(): try: NewUserData = User(form.username.data, form.password.data, form.name.data, form.email.data) print(NewUserData) db.session.add(NewUserData) db.session.commit() return redirect(url_for("login")) except: return redirect(url_for("register")) else: print(form.errors) return render_template('register.html', form=form)
def register(): form_register = RegisterForm() if form_register.validate_on_submit(): cadastro = User(username=form_register.username.data, password=form_register.password.data, name=form_register.name.data, email=form_register.email.data) db.session.add(cadastro) db.session.commit() login_user(cadastro) mensagem = "Usuário registrado e logado com sucesso! Seja bem vindo ao meu site: " + cadastro.username + "!" flash(mensagem) return redirect(url_for('principal')) else: return render_template('register.html', form_register=form_register)
def register(): form = RegisterForm() if form.validate_on_submit(): if not User.query.filter_by(email=form.email.data).first(): entry = User(name=form.name.data, email=form.email.data, password=form.password.data) entry.set_password(entry.password) db.session.add(entry) db.session.commit() flash(u"Registered!") else: flash(u"The user already exists!") return redirect(url_for('login')) return render_template('user/register.html', form=form)
def register(): form_register = RegisterForm() if form_register.validate_on_submit(): user = User.query.filter_by(username=form_register.username.data).first() if user: flash("Usuário já cadastrado") else: cadastrando = User(username=form_register.username.data, password=form_register.password.data, name=form_register.name.data, email=form_register.email.data) db.session.add(cadastrando) db.session.commit() login_user(cadastrando) flash("Usuário cadastrado e logado com sucesso") mensagem = "Seja bem vindo(a), " + cadastrando.name + "!" flash(mensagem) return redirect(url_for('index')) return render_template('register.html', form_register=form_register, navbar="")
def register(): rf = RegisterForm() if rf.validate_on_submit(): if rf.password.data == rf.password2.data: if rf.admin.data: user = User(rf.username.data, rf.password.data, 1) db.session.add(user) db.session.commit() flash('Registrado !') return redirect(url_for('index')) else: user = User(rf.username.data, rf.password.data, 0) db.session.add(user) db.session.commit() flash('Registrado !') return redirect(url_for('index')) else: flash('Senhas não condizem !') return render_template('register.html', rf=rf)
def register(): title = 'Cadastro' form = RegisterForm() if form.validate_on_submit(): user_result = Users.query.filter_by(username=form.username.data).all() if user_result: flash("Usuário já existe na base de dados!", "err") return redirect(url_for('register')) else: passwd_hashed = bcrypt.hashpw(form.passwd.data.encode('utf-8'), bcrypt.gensalt()) ins_user = Users(form.name.data, form.surname.data, form.username.data, passwd_hashed) db.session.add(ins_user) db.session.commit() flash("Usuário criados!", "inf") return redirect(url_for('login')) return render_template('register.html', title=title, form=form)
def register(): form = RegisterForm() if form.validate_on_submit(): user = User.query.filter_by(username=form.username.data).first() if user != None: flash("User already exists!") return redirect(url_for("index")) else: #INSERT i = User(form.username.data, form.password.data, form.name.data, form.email.data) db.session.add(i) db.session.commit() flash("Registered user!") return redirect(url_for("index")) return render_template('register.html', form=form)