Skip to content
Snippets Groups Projects
Commit 9ea369c4 authored by Josef Olsson's avatar Josef Olsson
Browse files

Remove get user(), uses one() instead

parent b3423040
No related branches found
No related tags found
No related merge requests found
Pipeline #44305 passed
......@@ -11,7 +11,7 @@ from app.apis import item_response, protect_route, text_response
from app.core import sockets
from app.core.codes import verify_code
from app.core.dto import AuthDTO
from app.database.models import Whitelist
from app.database.models import User, Whitelist
from flask import current_app
from flask_jwt_extended import create_access_token, get_jti, get_raw_jwt
from flask_jwt_extended.utils import get_jti
......@@ -87,7 +87,7 @@ class AuthDelete(Resource):
def delete(self, user_id):
""" Deletes the specified user and adds their token to the blacklist. """
item_user = dbc.get.user(user_id)
item_user = dbc.get.one(User, user_id)
# Blacklist all the whitelisted tokens
# in use for the user that will be deleted
......
......@@ -8,6 +8,7 @@ import app.database.controller as dbc
from app.apis import item_response, list_response, protect_route
from app.core.dto import UserDTO
from app.core.parsers import search_parser, sentinel
from app.database.models import User
from flask_jwt_extended import get_jwt_identity
from flask_restx import Resource, inputs, reqparse
......@@ -49,7 +50,7 @@ class UsersList(Resource):
def get(self):
""" Gets all users. """
item = dbc.get.user(get_jwt_identity())
item = dbc.get.one(User, get_jwt_identity())
return item_response(schema.dump(item))
@protect_route(allowed_roles=["*"])
......@@ -57,7 +58,7 @@ class UsersList(Resource):
""" Posts a new user using the specified arguments. """
args = user_parser_edit.parse_args(strict=True)
item = dbc.get.user(get_jwt_identity())
item = dbc.get.one(User, get_jwt_identity())
item = _edit_user(item, args)
return item_response(schema.dump(item))
......@@ -69,7 +70,7 @@ class Users(Resource):
def get(self, ID):
""" Gets the specified user. """
item = dbc.get.user(ID)
item = dbc.get.one(User, ID)
return item_response(schema.dump(item))
@protect_route(allowed_roles=["Admin"])
......@@ -77,7 +78,7 @@ class Users(Resource):
""" Edits the specified team using the provided arguments. """
args = user_parser_edit.parse_args(strict=True)
item = dbc.get.user(ID)
item = dbc.get.one(User, ID)
item = _edit_user(item, args)
return item_response(schema.dump(item))
......
......@@ -60,12 +60,6 @@ def user_exists(email):
return User.query.filter(User.email == email).count() > 0
def user(user_id):
""" Gets the user object associated with the provided user. """
return User.query.filter(User.id == user_id).first_extended()
def user_by_email(email):
""" Gets the user object associated with the provided email. """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment