Esempio n. 1
0
def post_login():
    email = request.form['email']
    password = request.form['password']

    user = User()
    try:
        response = user.autenticate(email, password)
        if response == False:
            return render_template(
                '/login.html',
                message="You have entered an invalid username or password",
                alertlevel="danger")
        else:
            cria_sessao(response.id, response.name, response.email,
                        response.permission, response.token)
            return render_template('/inicial.html',
                                   message="Welcome",
                                   alertlevel="success",
                                   user=response)
    except Exception as e:
        print(e)
        return render_template(
            '/login.html',
            message=
            "A database error has occurred. Contact your system administrator",
            alertlevel="danger")
Esempio n. 2
0
def logar(email, password):
    user = User()
    response = user.autenticate(email, password)
    if response == False:
        return jsonify({'response': 'Nenhum usuario encontrado'})
    elif response == 'ERRO':
        return jsonify({'response': 'Ocorreu um erro no servidor'})
    else:
        return json.dumps(para_dict(response))
def post_login():
    email = request.form['email']
    password = request.form['password']

    user = User()
    try:
        response = user.autenticate(email, password)
        if response == False:
            return render_template(
                '/login.html',
                message="You have entered an invalid username or password")
        else:
            session.pop('user', None)
            session['token'] = response.token
            session['id'] = response.id
            session['name'] = response.name
            session['user'] = request.form['email']
            session['permission'] = response.permission
            return render_template('/inicial.html', message=session['name'])
    except Exception as e:
        print(e)
        return "Erro no servidor. Contate o Analista"