Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
teknikattan-scoring-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tddd96-grupp1
teknikattan-scoring-system
Commits
9ea369c4
Commit
9ea369c4
authored
3 years ago
by
Josef Olsson
Browse files
Options
Downloads
Patches
Plain Diff
Remove get user(), uses one() instead
parent
b3423040
No related branches found
No related tags found
No related merge requests found
Pipeline
#44305
passed
3 years ago
Stage: setup
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
server/app/apis/auth.py
+2
-2
2 additions, 2 deletions
server/app/apis/auth.py
server/app/apis/users.py
+5
-4
5 additions, 4 deletions
server/app/apis/users.py
server/app/database/controller/get.py
+0
-6
0 additions, 6 deletions
server/app/database/controller/get.py
with
7 additions
and
12 deletions
server/app/apis/auth.py
+
2
−
2
View file @
9ea369c4
...
...
@@ -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
.
u
ser
(
user_id
)
item_user
=
dbc
.
get
.
one
(
U
ser
,
user_id
)
# Blacklist all the whitelisted tokens
# in use for the user that will be deleted
...
...
This diff is collapsed.
Click to expand it.
server/app/apis/users.py
+
5
−
4
View file @
9ea369c4
...
...
@@ -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
.
u
ser
(
get_jwt_identity
())
item
=
dbc
.
get
.
one
(
U
ser
,
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
.
u
ser
(
get_jwt_identity
())
item
=
dbc
.
get
.
one
(
U
ser
,
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
.
u
ser
(
ID
)
item
=
dbc
.
get
.
one
(
U
ser
,
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
.
u
ser
(
ID
)
item
=
dbc
.
get
.
one
(
U
ser
,
ID
)
item
=
_edit_user
(
item
,
args
)
return
item_response
(
schema
.
dump
(
item
))
...
...
This diff is collapsed.
Click to expand it.
server/app/database/controller/get.py
+
0
−
6
View file @
9ea369c4
...
...
@@ -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.
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment