コード例 #1
0
def addUser():
    addUserForm = RegistrationForm()

    if addUserForm.validate_on_submit():
        hashedPassword = bcrypt.generate_password_hash(
            addUserForm.password.data).decode('utf-8')
        user = User(
            username = addUserForm.username.data,
            fullname = addUserForm.fullname.data,
            email = addUserForm.email.data,
            password = hashedPassword,
            confirmed=True,
            confirmedOn = datetime.datetime.now(),
        )
        db.session.add(user)
        db.session.commit()

        userId = user.id
        return redirect(url_for('admin.index'))

    errors = "addUserErrors"
    users = User.query.all()
    requests = RightsRequest.query.all()
    return render_template('admin/main.html',
        addUserForm = addUserForm,
        users=users,
        requests = requests,
        errors = errors,)
コード例 #2
0
ファイル: views.py プロジェクト: damnOblivious/rapidannotator
def register():
    if current_user.is_authenticated:
        return redirect(url_for('home.index'))
    loginForm = LoginForm()
    registrationForm = RegistrationForm()

    if registrationForm.validate_on_submit():
        hashedPassword = bcrypt.generate_password_hash(
            registrationForm.password.data).decode('utf-8')

        user = User(username=registrationForm.username.data,
                    fullname=registrationForm.fullname.data,
                    email=registrationForm.email.data,
                    password=hashedPassword)
        db.session.add(user)
        db.session.commit()

        flash(
            _('Thank you, you are now a registered user. \
                Please Login to continue.'))

        return render_template('frontpage/main.html',
                               loginForm=loginForm,
                               registrationForm=registrationForm)

    errors = "registrationErrors"
    return render_template(
        'frontpage/main.html',
        loginForm=loginForm,
        registrationForm=registrationForm,
        errors=errors,
    )
コード例 #3
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('home.index'))
    loginForm = LoginForm()
    registrationForm = RegistrationForm()
    forgotPasswordForm = ForgotPasswordForm()

    if registrationForm.validate_on_submit():
        hashedPassword = bcrypt.generate_password_hash(
            registrationForm.password.data).decode('utf-8')

        user = User(username=registrationForm.username.data,
                    fullname=registrationForm.fullname.data,
                    email=registrationForm.email.data,
                    password=hashedPassword,
                    confirmed=False)
        db.session.add(user)
        db.session.commit()

        token = generate_confirmation_token(user.email)
        confirm_url = url_for('frontpage.confirm_email',
                              token=token,
                              _external=True)
        html = render_template('frontpage/activate.html',
                               confirm_url=confirm_url)
        subject = "Please confirm your email"
        send_email(registrationForm.email.data, subject, html)

        flash(
            _('Thank you, you are now a registered user. \
            A confirmation email has been sent. \
                Please confirm your Email for the Login.'))

        return redirect(url_for('frontpage.index'))

    errors = "registrationErrors"
    return render_template(
        'frontpage/main.html',
        loginForm=loginForm,
        registrationForm=registrationForm,
        forgotPasswordForm=forgotPasswordForm,
        otpShow=0,
        errors=errors,
    )