Beispiel #1
0
def register_post():
    form = RegisterForm(request.form)
    if form.validate():
        if not AuthHelper.check_user_exist(form.email.data,
                                           form.username.data):
            # Create new user
            user = User()
            user.username = form.username.data
            user.password = generate_password_hash(form.password.data)
            user.email = form.email.data
            user.generate_encryption_keys(form.password.data)
            # Add to db
            db.session.add(user)
            db.session.commit()
            mailer.send_confirmation_mail(form.username.data, form.email.data)
            Flasher.flash(
                "Register Successful, please check your mail address for confirmation",
                "success")
            return redirect(url_for('app_login.login_get'))
        else:
            Flasher.flash("This username or email address is already in use",
                          "warning")
    else:
        Flasher.flash_errors(form, "danger")
    return redirect(url_for('app_register.register_get'))
Beispiel #2
0
def create_user(email: str, nick_name: str,
                first_name: str, last_name: str, register_type: int) -> User:
    user = User()
    user.email = email
    user.nick_name = nick_name
    user.first_name = first_name
    user.last_name = last_name
    user.register_type = register_type
    return user
Beispiel #3
0
def createdb():
    db.drop_all()
    db.create_all()
    user = User()
    user.username = '******'
    user.password = generate_password_hash('asd')
    user.email = '*****@*****.**'
    user.generate_encryption_keys('asd')
    user.is_confirmed = True
    db.session.add(user)
    db.session.commit()
    login_user(user)
    session['rand_key'] = user.get_random_key('asd')
    return "OK"
Beispiel #4
0
def migrate_user():
    from projectl.models import User as Ul
    from project.models import User as Um

    for i in Ul.query.all():
       u = Um(password='******')
       u.id = i.id
       u.username = i.username
       u.first_name = i.first_name
       u.last_name = i.last_name
       u.department = i.department
       u.position = i.position
       u.local_number = i.local_number
       u.password = i.password
       u.email = i.email
       u.active = i.active
       u.password = i.password
       u.active = i.active
       db.session.add(u)

    db.session.commit()