Beispiel #1
0
def load_user_from_request(request):
    token = request.headers.get('Authorization')
    if token:
        user = Usuario().verify_auth_token(token)
        if user:
            return user
    return None
Beispiel #2
0
def login():
    user_name = request.form.get('name')
    user_psw = request.form.get('password')
    remember_me = True if request.form.get('rememberme') else False
    if Usuario().login(user_name, user_psw, remember_me):
        return redirect('{}/minhasAvaliacoes'.format(
            os.environ.get('HOST_ENDPOINT', request.url_root[:-1])))
    return render_template('login.html', mensagem='Usuário/senha incorretos')
Beispiel #3
0
    def test_logout(self, mock_logout):
        Usuario().logout()

        mock_logout.assert_called_once_with()
Beispiel #4
0
def load_user(user_id):
    return Usuario().obter_por_id(user_id)
Beispiel #5
0
def logout():
    Usuario().logout()
    return redirect('{}/'.format(
        os.environ.get('HOST_ENDPOINT', request.url_root[:-1])))