예제 #1
0
def do_login(request):
    params = request.get_json()
    mail = params['mail']
    password = params['user_password']
    user = Users.confirm_account(mail, password)
    print(user)
    return json.dumps({'result': user is not None, 'user': user})
예제 #2
0
def login():
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        if Users.confirm_account(username, password):
            res = {'result': 'True'}
            return json.dumps(res)

        else:
            res = {'result': 'False', 'error': 'user or password error'}
            return json.dumps(res)

    else:
        return Response('''
            <form action="" method="post">
                <p><input type=text name=username>
                <p><input type=password name=password>
                <p><input type=submit value=Login>
            </form> 
            ''')