Пример #1
0
def signup():
    title = "Registration Form"
    error = None
    form = RegistrationForm()

    if request.method == 'POST' and form.validate_on_submit():

        if users.find_one({'username': form.username.data}) is None:

            hashpw = generate_password_hash(form.password.data)
            users.insert({
                'username': form.username.data,
                'password': hashpw,
                'name': form.name.data,
                'email': form.email.data
            })

            new_user = User(form.username.data)
            login_user(new_user)

            session['logged_in'] = True
            session['username'] = form.username.data

            flash('Registration Successfull', 'success')
            return redirect(url_for("dashboard"))

        else:
            error = "Username already exists."

    return render_template("signup.html", form=form, title=title, error=error)
Пример #2
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        flash(f'Account Created for {form.username.data}!', 'success')
        return redirect(url_for('login'))

    return render_template('register.html', title='Register', form = form)
Пример #3
0
def registration():
    form = RegistrationForm()
    if form.validate_on_submit():  # Обрабатываем метод POST
        # Выполняем проверку на уникальность параметра 'Email' перед записью в базу данных.
        new_email = form.email.data  # Получаем введеный пользователем email
        email = User.query.filter_by(
            email=new_email).first()  # Делаем запрос к базе дыннх.
        # Если пользователь с таком Email нет в базе данных,регистрируем его
        if email is None:
            New_user(
                form
            )  # Данны с формы отправляем в другой модуль,для записи в db
            flash(
                'Регистрация прошла успешно.\n'
                'Пожалуйста, перейдите по ссылке, чтобы подтвердить свою регистрацию.\n'
                'Мы отправили электронное письмо на указанный почтовый адрес.')
            return redirect(url_for('main'))
        else:
            # Если пользователь с таким Email зарегистрирован в базе,тогда сообщаем об этом.
            flash(
                f'Пользователь с адресом "{new_email}" уже зарегистрирован на сайте.'
            )
            return redirect(url_for('registration'))
    else:
        return render_template('registration.html', form=form)
Пример #4
0
def signup():
    form = RegistrationForm()

    if form.validate_on_submit():
        username1 = form.username.data
        phone1 = form.phone.data
        email1 = form.email.data
        password1 = form.password.data
        company = form.companyname.data
        cur = con.cursor()
        cur.execute("SELECT * from usertable WHERE email='" + email1 + "'")
        data = cur.fetchone()
        if (data != []):
            cur.execute(
                "INSERT INTO usertable (username,email,password,phone,company) VALUES (%s,%s,%s,%s,%s)",
                (username1, email1, password1, phone1, company))
            con.commit()
            flash(f'Account succesfully created for {username1}! Just Login',
                  'success')
            return redirect(url_for('index'))
        else:
            flash(f'Given Email ID is already Used', 'danger')
            return render_template("signup.html",
                                   title='Inventory|signup',
                                   form=form)
    return render_template("signup.html", title='Inventory|signup', form=form)
Пример #5
0
def register():
    form = RegistrationForm()
 
    if form.validate_on_submit():
        
        #make sure an existing user doesn't already exist
        exists = False
        try:
            u = User_db.objects.get(id=(request.form['username']))
            exists = True
        except:
            print("")

        if exists:
            flash("that username already exists")
            return redirect("/register")
        

        #hash password
        hash_pw = sha256_crypt.hash(request.form['password'])

        #store data in db
        new_user = User_db(id = request.form['username'], password = hash_pw).save()

        return redirect("/login") #CHANGE
    elif request.method == "POST":
        flash("bad registration")
        return redirect("/register")                    
        
    print(form.errors)
    return render_template("register.html", form = form)
Пример #6
0
def register():
    registrationform = RegistrationForm()
    if registrationform.validate_on_submit():
        flash(
            "Account successfully create for %s" %
            (registrationform.username.data), "success")
        return redirect(url_for('home'))
    return render_template("register.html", registrationform=registrationform)
Пример #7
0
def register():
    form = RegistrationForm()
    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('注册完成')
        return redirect(url_for('auth.login'))
    return render_template('auth/register.html', form=form)
Пример #8
0
def register():
    form = RegistrationForm()
    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('注册完成')
        return redirect(url_for('auth.login'))
    return render_template('auth/register.html',form=form)
Пример #9
0
def register():
    form1 = RegistrationForm()
    print form1
    if form1.validate_on_submit():
        user = User(email=form1.email.data, username=form1.username.data, password=form1.password.data)
        session.add(user)
        session.commit()
        session.close()
        flash('You can now login.')
        return redirect(url_for('auth.login'))
    return render_template('auth/register.html', form=form1)
Пример #10
0
def register():
    form = RegistrationForm(request.form)
    if form.validate_on_submit():
          user = User(name=form.username.data,
                      email=form.email.data,
                      password=form.password.data)
          db.session.add(user)
          db.session.commit()
          login_user(user)
          flash("Welcome to the site")
          return redirect(url_for('home.home'))
    return render_template('register.html',form=form)
Пример #11
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('frontPage'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = models.User(username=form.username.data, email=form.email.data)
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('You are now registered!')
        return redirect(url_for('logIn'))
    return render_template('register.html', title='Register', form=form)
Пример #12
0
def register():
    if current_user.is_authenticated:
        redirect(url_for('index'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(username=form.username.data, email=form.email.data)
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('Congratulations, you are now a registered user!')
        return redirect(url_for('login'))
    return render_template("register.html", title='Registration', form=form)
Пример #13
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('main'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = BookUser(username=form.username.data,
                        password=form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('You can now login')
        return redirect(url_for('login'))
    return render_template('register.html', form=form)
Пример #14
0
def reg():
    form = RegistrationForm()
    if form.validate_on_submit():
        hashed_password = generate_password_hash(form.password.data,
                                                 method='sha256')
        new_user = User(username=form.username.data,
                        email=form.email.data,
                        password=hashed_password)
        db.session.add(new_user)
        db.session.commit()

        return redirect(url_for('login'))
    return render_template('index.html', form=form)
Пример #15
0
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,
                    _email=form.email.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)
Пример #16
0
def register():
    form = RegistrationForm()
    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()
        token = user.generate_confirmation_token()
        send_email(user.email, 'Confirm Your Account',
                   'email/confirm', user=user, token=token)
        flash('A confirmation email has been sent to you by email.')
        return redirect(url_for('login'))
    return render_template('register.html', form=form)
Пример #17
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('all_donation'))
    form = RegistrationForm()
    if form.validate_on_submit():
        hashed_pass = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        new_donor = Donor(username=form.username.data,
                          name=form.name.data,
                          password=hashed_pass)
        new_donor.save()
        flash(f'Account created for {form.name.data}!, you can now log in',
              'success')
        return redirect(url_for('login'))
    return render_template('register.jinja2', title='register', form=form)
Пример #18
0
def Register():
    registration_form = RegistrationForm()
    if registration_form.submit2.data and \
        registration_form.validate_on_submit():
        user = (db_session.query(User).filter_by(
            email=registration_form.email.data).first())
        if user is None:
            new_user = User(name=registration_form.name.data,
                            email=registration_form.email.data)
            new_user.password = registration_form.password.data
            db_session.add(new_user)
            db_session.commit()
            flash('Registration successful. \
                Please Log in with the credentials')
            return redirect(url_for('Home'))
        flash('User already exists. Please log in')
    return render_template('register.html', form=registration_form)
Пример #19
0
def registration():
    registration_form = RegistrationForm()
    if registration_form.validate_on_submit():
        email = request.form.get('email')
        name = request.form.get('name')
        password = request.form.get('password')

        user = User.query.filter_by(email=email).first()
        if user:
            flash('Email already exist')
            return redirect(url_for('auth.registration'))
        new_user = User(email=email, name=name, password=generate_password_hash(password=password, method='sha256'))
        db.session.add(new_user)
        db.session.commit()
        flash('Thanks for registartion')
        return redirect(url_for('auth.login'))
    return render_template('registration.html', form=registration_form)
Пример #20
0
def register():
	if current_user.is_authenticated:
		return redirect(url_for('main.index'))
	form = RegistrationForm()
	if form.validate_on_submit():
		user = User(email=form.email.data,
							username=form.username.data,
							password=form.password.data)

		# add employee to the database
		db.session.add(user)
		db.session.commit()
		flash('You have successfully registered! You may now login.')

		# redirect to the login page
		return redirect(url_for('authentication.login'))

	# load registration template
	return render_template('users/register.html', form=form, title='Register')
Пример #21
0
def register():
    username = None
    email = None
    password = None
    cpassword = None

    form = RegistrationForm()
    if form.validate_on_submit():
        username = form.username.data
        email = form.email.data
        password = form.password.data

        login = User(username=username, email=email, password=password)

        db.session.add(login)
        db.session.commit()

        return f'<h1>{form.username.data}, you have been registered successfully! Click <a href="/login">here</a> to login.</h1>', 'success'
    return render_template('register.html', title='Register', form=form)
Пример #22
0
def register():

    register = RegistrationForm()
    registerError = None
    if register.validate_on_submit():
        user_unique = User.query.filter_by(username=register.username.data).first()
        email_unique = User.query.filter_by(email=register.email.data).first()
        if user_unique is None and email_unique is None:

            user = User(register.fullname.data, register.username.data, register.email.data, register.password.data)
            db.session.add(user)
            db.session.commit()
            login_user(user)
            flash("Thank's for registering")
            return redirect(url_for("index"))
        else:
            registerError = "Email or Username already taken"
    return render_template(
        "login.html", form1=register, form2=LoginForm(), loginError=None, registerError=registerError
    )
Пример #23
0
def register():
    form = RegistrationForm()
    connection = connect()
    bcrypt = Bcrypt()
    if form.validate_on_submit():
        try:
            cursor = connection.cursor()
            username = form.username.data
            email = form.email.data
            password = form.password.data
            hashed_password = bcrypt.generate_password_hash(password).decode(
                'utf-8')
            sql = "INSERT INTO users (username, email, password) VALUES (%s, %s, %s)"
            cursor.execute(sql, (username, email, hashed_password))
            connection.commit()
            flash('Account created successfully!', 'success')
            return redirect(url_for('login'))

        finally:
            connection.close()

    return render_template('register.html', title='Register Page', form=form)
Пример #24
0
def contact():
    """Render the website's contact page."""
    c_form = RegistrationForm(request.form)

    if request.method == "POST":
        if c_form.validate_on_submit():
            user_name = c_form.name.data
            user_email = c_form.email.data
            subject = c_form.subject.data
            text = c_form.message.data

            msg = Message(subject,
                          sender=(user_name, user_email),
                          recipients=["*****@*****.**"])

            msg.body = text

            mail.send(msg)

            flash("Email Sent.")
            return redirect(url_for('home'))

    return render_template('contact.html', form=c_form)
Пример #25
0
def registration():
    form = RegistrationForm()
    if form.validate_on_submit():
        username = form.username.data
        password = form.password.data
        password_confirm = form.password_confirm.data
        email = form.email.data

        if password == password_confirm and \
                LibraryUser.query.filter_by(username=username).first() is None:
            user = LibraryUser(username=username,
                               password_hash=generate_password_hash(password),
                               email=email,
                               about_me='')

            db.session.add(user)
            db.session.commit()

            session['username'] = username
            session['user_id'] = user.id

            return redirect('/')
    return render_template('registration.html', session=session, form=form)
def register():
    form = RegistrationForm()
    # print(form.validate_on_submit())
    if form.validate_on_submit():
        return redirect(url_for('home'))
    return render_template('register.html', title='Register', form=form)
Пример #27
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        flash(f'Account created for {form.userName.data}!', category="success")
        return redirect(url_for('home'))
    return render_template('register.html', title='Register', form=form)
Пример #28
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        flash('Account created for %s!' % (form.username.data), 'success')
        return redirect(url_for('home'))
    return render_template('register.html', title="Register", form=form)
Пример #29
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        flash(f'Create Success for {form.username.data}!', 'success')
        return redirect(url_for('index'))
    return render_template('register.html', form=form)
Пример #30
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        flash(f'{form.name.data} has been registered')
        return redirect(url_for('home'))
    return render_template('register.html', form=form)