示例#1
0
def newAccount():
    cursor.execute('select name, login, status from account where id = %s',
                   (current_user.id, ))
    user = cursor.fetchone()
    if user[2] == 0:
        flash('Отказано в доступе')
        return redirect(url_for('account'))
    form = CreateAccountForm()
    if form.validate_on_submit():
        cursor.execute('select * from account where login = %s',
                       (form.login.data, ))
        check_user = cursor.fetchone()
        if check_user:
            flash('Учетная запись с таким логином уже существует!')
            return redirect(url_for('newAccount'))
        cursor.execute(
            'insert into account (login, passwordHash, name, status) values (%s, %s, %s, %s);',
            (
                form.login.data,
                generate_password_hash(form.password.data),
                form.name.data,
                form.level.data,
            ))
        conn.commit()
        flash('Учетная запись для {} создана успешно!'.format(form.name.data))
        flash('Login: {}'.format(form.login.data))
        flash('Password: {}'.format(form.password.data))
        return redirect(url_for('account'))
    return render_template('newAccount.html',
                           title='Создание аккаунта',
                           form=form,
                           user=user)
示例#2
0
def createAccount():
    #URL = "https://ofe3yhbyec.execute-api.us-east-1.amazonaws.com/beta/testapicall"

    accountForm = CreateAccountForm()
    if accountForm.validate_on_submit():
        first = accountForm.firstName.data
        last = accountForm.lastName.data
        zipCode = accountForm.zipCode.data

        user = accountForm.email.data
        password = accountForm.password.data

        if accountForm.check_password(password):
            URL = "https://ofe3yhbyec.execute-api.us-east-1.amazonaws.com/beta/socdoc-create-account?username=%s&password=%s&firstname=%s&lastname=%s&zipcode=%s" % (
                user, password, first, last, zipCode)
            print(URL)
            r = requests.get(url=URL)
            print("\n")
            print(r.json())
            #print(type(r.json()))
            #flash('New Account requested for user {}'.format(accountForm.firstName.data))
            return redirect(
                url_for('createAccount_success',
                        first=first,
                        last=last,
                        user=user))

    return render_template('createAccount.html',
                           title='Create Account',
                           form=accountForm)
示例#3
0
文件: routes.py 项目: TMust98/Agency
def createAccount():
    if current_user.is_authenticated:
        flash('Для регистрации нового аккаунта выйдите из существующего')
        return redirect(url_for('account'))
    form = CreateAccountForm()
    if form.validate_on_submit():
        cursor.execute('select * from account where login = %s;',
                       (form.login.data, ))
        user = cursor.fetchone()
        if user:
            flash('Учетная запись с таким логином уже существует!')
            return redirect(url_for('createAccount'))
        if form.passwordOne.data == form.passwordTwo.data:
            cursor.execute(
                'insert into account (login, passwordHash, idTypeAccountOne, idTypeAccountTwo, idFirm) values (%s, %s, 1, 1, 1);',
                (
                    form.login.data,
                    generate_password_hash(form.passwordOne.data),
                ))
            conn.commit()
            cursor.execute('select id from account where login = %s;',
                           (form.login.data, ))
            user = cursor.fetchone()
            login_user(load_user(user[0]), remember=0)
            flash('Учетная запись создана успешно. Заполните данные профиля.')
            return redirect(url_for('fillAccount'))
        else:
            flash('Пароли не совпадают.')
            return redirect(url_for('createAccount'))
    return render_template('createAccount.html',
                           title='Создание аккаунта',
                           form=form)
示例#4
0
def create_user():
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    form = CreateAccountForm()
    if form.validate_on_submit():
        new_user = form.username.data
        if User.query.filter_by(username=new_user).first() is not None:
            flash('User Already Exists')
        else:
            flash("New User {} Created!".format(form.username.data))
            country = form.country.data
            country = string.capwords(country)
            if Country.query.filter_by(name=form.country.data).first() is not None:
                c =Country.query.filter_by(name=form.country.data).first()
            else:
                c = Country(name=form.country.data)
                db.session.add(c)
                db.session.commit()
            u1 = User(username=form.username.data, email=form.email.data, countryID=c.id)
            u1.set_password(form.password.data)
            db.session.add(u1)
            db.session.commit()
        return redirect('/login')

    return render_template('create_user.html', title="Create User", form=form)
示例#5
0
def createAccount():
    accountForm = CreateAccountForm()
    if accountForm.validate_on_submit():
        flash('New Account requested for user {}'.format(
            accountForm.firstName.data))
        return redirect(url_for('index'))
    return render_template('createAccount.html',
                           title='Create Account',
                           form=accountForm)
示例#6
0
def create_account():
    form = CreateAccountForm()
    if form.validate_on_submit():
        flash(
            f"New account requested for user {form.username.data}, email={form.email.data}"
        )
        return redirect(url_for("login"))
    return render_template("create_account.html",
                           title="Create Account",
                           form=form)
示例#7
0
def create_account():
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    form = CreateAccountForm()
    if form.validate_on_submit():
        user = User(username=form.username.data)
        user.set_password(form.password.data)
        user.save_to_db()
        flash('Account Creation successful')
        return redirect(url_for('login'))
    return render_template('create-account.html', form=form)
示例#8
0
def newuser():
    form = CreateAccountForm()
    if form.validate_on_submit():
        flash(
            'Login requested for user {}, remember_me={}, e {}, p {}, cp {}, pn {}, sa {}'
            .format(form.first_name.data, form.last_name.data,
                    form.email_address.data, form.password.data,
                    form.confirm_password.data, form.phone_number.data,
                    form.security_answers.data))
        return redirect('/confirmation')
    return render_template('create_account.html',
                           title='Create Account',
                           form=form)
示例#9
0
def newuser():
    if current_user.is_authenticated:
        return redirect(url_for("index"))
    form = CreateAccountForm()
    if form.validate_on_submit():
        user = User()
        user.username = form.username.data
        user.set_password(form.password.data)
        user.discord_name = form.discord_name.data
        user.pronunciation = form.pronunciation.data
        user.pronouns = form.pronouns.data
        user.interesting_facts = form.about.data
        db.session.add(user)
        db.session.commit()
        login_user(user, remember=False)
        return redirect(url_for("index"))
    return render_template("create_account.html", form=form)
示例#10
0
def create_account():
    form = CreateAccountForm()
    if form.validate_on_submit():
        flash("Form successfully submitted", "success")
        return redirect(url_for("index"))
    return render_template("create_account.html", form=form)