Exemplo n.º 1
0
def signup():
    form = SignupForm()
    if form.validate_on_submit():
        user = User(email=form.email.data)
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('Account is created. Now you can sign in.', 'success')
        return redirect(url_for('.signin'))
    return render_template('users/signup.html', form=form)
Exemplo n.º 2
0
def signup():
    form = SignupForm()
    if form.validate_on_submit():
        user = User(email=form.email.data)
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('Account is created. Now you can sign in.', 'success')
        return redirect(url_for('signin'))
    return render_template('users/signup.html', form=form)
Exemplo n.º 3
0
def signin():
    form = SigninForm()
    if form.validate_on_submit():
        auth_user = User.authenticate(form.email.data, form.password.data)
        if auth_user:
            login_user(auth_user)
            flash('You are signed in!', 'success')
            return redirect(url_for('.home'))
        else:
            flash('Wrong email or password', 'error')
    return render_template('users/signin.html', form=form)
Exemplo n.º 4
0
def signin():
    form = SigninForm()
    if form.validate_on_submit():
        auth_user = User.authenticate(form.email.data, form.password.data)
        if auth_user:
            login_user(auth_user)
            flash('You are signed in!', 'success')
            return redirect(url_for('home'))
        else:
            flash('Wrong email or password', 'error')
    return render_template('users/signin.html', form=form)
Exemplo n.º 5
0
 def create_user(self, **kwargs):
     user = User(email=kwargs['email'])
     user.set_password(kwargs['password'])
     db.session.add(user)
     db.session.commit()
     return user
Exemplo n.º 6
0
 def create_user(self, **kwargs):
     user = User(email=kwargs['email'])
     user.set_password(kwargs['password'])
     db.session.add(user)
     db.session.commit()
     return user