Example #1
0
def login():
    result = {}
    if 'username' not in request.form or 'password' not in request.form:
        result['error'] = True
        return redirect(url_for('auth.auth'), 302, result)

    username = request.form['username']
    password = hashlib.sha512(request.form['password']).hexdigest()

    # checking for authentication
    auth_resp = Auth.authorize(username, password)
    session['username'] = username

    if auth_resp['success']:
        return redirect(url_for('auth.dashboard'))
    else:
        result['error'] = True
        return redirect(url_for('auth.auth'), 302, result)
Example #2
0
def getKey():
    response = {}
    if 'username' not in request.form or 'password' not in request.form:
        response['error'] = True
        return jsonify(response)

    username = request.form['username']
    password = hashlib.sha512(request.form['password']).hexdigest()

    #checking for authentication
    auth_resp = Auth.authorize(username, password)

    if auth_resp['success']:
        response['error'] = False
        response['key'] = auth_resp['key']
    else:
        response['error'] = True

    return jsonify(response)