def register(): """Registration Page""" form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): user = User(form.email.data, form.password.data) user.save() flash('Thanks for registering') return redirect('/') return render_template('user/register.html', form=form)
def sign_in(): """Log the user into the server""" # Check for the correct form data to be submitted if "user[password]" not in request.form or "user[email]" not in request.form: abort(400) # Get the user and check the password user = User.get_by_email(request.form["user[email]"]) if user and user.check_password(request.form["user[password]"]): # If the user and credentials are valid, log the user in login_user(user) return jsonify(success=True) # Something went wrong return jsonify(success=False, errors=["Login Failed"])
def sign_in(): """Log the user into the server""" # Check for the correct form data to be submitted if 'user[password]' not in request.form \ or 'user[email]' not in request.form: abort(400) # Get the user and check the password user = User.get_by_email(request.form['user[email]']) if user and user.check_password(request.form['user[password]']): # If the user and credentials are valid, log the user in login_user(user) return jsonify(success=True) # Something went wrong return jsonify(success=False, errors=['Login Failed'])
def load_user(userid): """Load the user for the user manager""" return User.get(userid)