feat(Users): Implemented Kratos CRUD
This commit is contained in:
parent
a208b5f441
commit
a81d14b4f8
10 changed files with 99 additions and 48 deletions
1
areas/auth/__init__.py
Normal file
1
areas/auth/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
from .auth import *
|
||||
21
areas/auth/auth.py
Normal file
21
areas/auth/auth.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
from flask import request, jsonify
|
||||
from flask_jwt_extended import create_access_token
|
||||
from flask_cors import cross_origin
|
||||
|
||||
from areas import api_v1
|
||||
|
||||
USERNAME = 'admin'
|
||||
PASSWORD = 'admin'
|
||||
|
||||
|
||||
@api_v1.route('/login', methods=['POST'])
|
||||
@cross_origin()
|
||||
def login():
|
||||
username = request.json.get('username')
|
||||
password = request.json.get('password')
|
||||
|
||||
if username != USERNAME or password != PASSWORD:
|
||||
return jsonify({'errorMessage': 'Invalid username or password'}), 401
|
||||
|
||||
access_token = create_access_token(identity=username)
|
||||
return jsonify({'username': USERNAME, 'access_token': access_token})
|
||||
Reference in a new issue