Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit f459ac2

Browse files
committed
v0.9.15:Enhanced Auth Hook
1 parent fd004f5 commit f459ac2

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

libfreeiot/core/routes.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"""
66
import os
77
import datetime
8-
from flask import request, jsonify
8+
from bson import json_util
9+
from flask import request, jsonify, Response
910
from flask_restful import Api
1011
from flask_jwt_simple import JWTManager, create_jwt
1112
from .resources.device import Device
@@ -44,13 +45,18 @@ def auth():
4445
if not password:
4546
return jsonify({"msg": "Missing password parameter"}), 400
4647
if 'auth'in scope.keys():
47-
if not scope["auth"].login(username, password):
48+
authr = scope["auth"].login(username, password)
49+
if not authr:
4850
return jsonify({"msg": "Bad username or password"}), 401
4951
else:
5052
if username != 'admin' or password == 'admin':
5153
return jsonify({"msg": "Bad username or password"}), 401
52-
53-
return jsonify({'jwt': create_jwt(identity=username)}), 200
54+
res = authr or {}
55+
res["jwt"] = create_jwt(identity=username)
56+
return Response(
57+
json_util.dumps(res),
58+
mimetype='application/json'
59+
), 200
5460

5561
# RESTFul API Routes definition
5662
api = Api(app)

libfreeiot/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
"""
55

66
script_name = 'libfreeiot'
7-
__version__ = '0.9.14'
7+
__version__ = '0.9.15'

0 commit comments

Comments
 (0)