Example #1
0
def login_post():
    if current_user.is_authenticated:
        return redirect(url_for('home.index'))

    email = request.form.get('email')
    password = request.form.get('password')
    remember = True if request.form.get('remember') else False
    user = User.query.filter_by(email=email).first()

    if (not user and User.isSuperAdmin(email)):
        user = User.getSuperAdmin()

    if not user or not check_password_hash(user.password, password):
        flash('Please check your login details and try again.')
        return redirect(url_for('auth.login'))

    login_user(user, remember=remember)
    return redirect(url_for('home.index'))
Example #2
0
 def load_user(user_id):
     user = User.query.get(int(user_id))
     if (not user and User.getSuperAdmin().id == int(user_id)):
         user = User.getSuperAdmin()
     return user