You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from flask_mongoalchemy import Document
my class
class User(Document):
id = db.StringField()
email = db.StringField()
password = db.StringField()
name = db.StringField()
`from flask import request, make_response, jsonify, current_app
from time import time
from app.models import User
from app.security import bp
@bp.route('/freeman/login', methods=['POST'])
def login():
email = request.json['email']
password = request.json['password']
user = User.query.filter(User.email == email)
if user is None or not user.check_password(password):
return make_response(jsonify({'error': 'Unauthorized access'}), 401)
expires_in = time() + current_app['EXPIRATION_TIME']
secret_key = current_app['SECRET_KEY']
token = user.login(secret_key, expires_in)
return make_response(jsonify({'type': 'bearer', 'token': token, 'expireIn': expires_in}), 200)
Flask-MongoAlchemy==0.7.2
from flask_mongoalchemy import Document
my class
class User(Document):
id = db.StringField()
email = db.StringField()
password = db.StringField()
name = db.StringField()
`from flask import request, make_response, jsonify, current_app
from time import time
from app.models import User
from app.security import bp
@bp.route('/freeman/login', methods=['POST'])
def login():
email = request.json['email']
password = request.json['password']
user = User.query.filter(User.email == email)
if user is None or not user.check_password(password):
return make_response(jsonify({'error': 'Unauthorized access'}), 401)
expires_in = time() + current_app['EXPIRATION_TIME']
secret_key = current_app['SECRET_KEY']
token = user.login(secret_key, expires_in)
return make_response(jsonify({'type': 'bearer', 'token': token, 'expireIn': expires_in}), 200)
@bp.route('/freeman/api/users', methods=['GET'])
def get_users():
users = User.query.all()
return make_response(jsonify({'users': users}), 200)`
I debugged and I don know what's happens, but my query object has no instance and looking the documentation it's OK
The text was updated successfully, but these errors were encountered: