- No more direct access to g.current_user, unless unavoidable. - Using pillar.auth.current_user instead of g.current_user or flask_login.current_user. - p.a.current_user is never checked against None. - p.a.current_user.is_authenticated or is_anonymous is used, and never together with a negation (instead of 'not is_anon' use 'is_auth'). - No more accessing current_user a a dict. - No more checks for admin role, use capability check instead.
22 lines
505 B
Python
22 lines
505 B
Python
import logging
|
|
|
|
from eve.methods.get import get
|
|
from flask import Blueprint
|
|
|
|
from pillar.api.utils import jsonify
|
|
from pillar.api.utils.authorization import require_login
|
|
from pillar.auth import current_user
|
|
|
|
log = logging.getLogger(__name__)
|
|
blueprint_api = Blueprint('users_api', __name__)
|
|
|
|
|
|
@blueprint_api.route('/me')
|
|
@require_login()
|
|
def my_info():
|
|
eve_resp, _, _, status, _ = get('users', {'_id': current_user.user_id})
|
|
resp = jsonify(eve_resp['_items'][0], status=status)
|
|
return resp
|
|
|
|
|