Example #1
0
def get_token():
    request_data = request.get_json()
    username = str(request_data['username'])
    password = str(request_data['password'])
    match = User.username_password_match(username, password)

    if (match):
        expiration_date = datetime.datetime.utcnow() + datetime.timedelta(
            seconds=100)
        token = jwt.encode({'exp': expiration_date},
                           app.config['SECRET_KEY'],
                           algorithm='HS256')
        return token
    else:
        return Response("", 401, mimetype='application/json')
 def testMatchUsernamePassword(self):
     response = User.username_password_match('admin', '12345')
     self.assertEqual(response, True)