Exemple #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
Exemple #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')
Exemple #3
0
    def test_logout(self, mock_logout):
        Usuario().logout()

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