Beispiel #1
0
def register_user():
    """
    Register a new user.
    """
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']

        try:
            User.register_user(username, password)
            # A session is a piece of data that is stored inside the app for each user different.
            session['username'] = username
            Log(username, 'Register.').save_to_mongo()
            flash('You have successfully registered.', 'success')
            return redirect(url_for('libors.index'))

        except errors.UserError as e:
            # Make the password strength error shorter.
            if e.message.startswith('A password must'):
                Log(username, 'Password strength error.').save_to_mongo()
            else:
                Log(username, e.message).save_to_mongo()
            flash(e.message, 'danger')
            return render_template('users/register.html')
    # If it's GET method, send user to the register page.
    return render_template('users/register.html')
Beispiel #2
0
def register_user():
    if request.method == 'POST':
        email = request.form['email']
        password = request.form['password']

        try:
            User.register_user(email, password)
            session['email'] = email
            return email
        except UserErrors.UserError as e:
            return e.message
    return render_template('users/register.html')
Beispiel #3
0
def register_user():
    if request.method == 'POST':
        email = request.form['email']
        password = request.form['password']

        try:
            User.register_user(email, password)
            session['email'] = email
            return redirect(url_for('alerts.index'))
        except UserErrors.UserError as e:
            flash(e.message, 'danger')
            return render_template('users/login.html')

    return render_template('users/register.html')
def signup():
    form = RegistrationForm()

    if form.validate_on_submit():
        user = User(form.email.data, form.password.data, form.name.data,
                    form.company.data)
        try:
            user.register_user()
            session['email'] = user.email
            flash(
                'Sign up is complete, enjoy our services. \nAn E-mail address verification link has been sent to {0}.'
                .format(form.email.data), 'success')
            return redirect(url_for('users.mail_verification'))
        except UserErrors.UserAlreadyRegisteredError as e:
            flash(e.message, 'danger')
    return render_template('signup.html', form=form)
Beispiel #5
0
def register_user():
    if request.method == 'POST':
        name = request.form['name']
        lastname = request.form['lastname']
        email = request.form['email']
        password = request.form['password']

        try:
            if User.register_user(name, lastname, email, password):
                session['email'] = email
                return redirect(url_for('home.index'))
        except UserErrors.UserError as e:
            return e.message
    
    try:
        if  User.find_by_email(session['email']):
            return redirect(url_for('home.index'))
    except:
        pass


    return render_template("users/register.html")  # Send the user an error if their login was invalid