def METHOD_NAME(email):
    user = User.get_by_email(email)
    if current_user.is_authenticated:
        logout_user()
    if user is None:
        flash("Your email address was not recognised")
    else:
        login_user(user)
        session.permanent = True
    return redirect(get_next_url())