Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
library-app-django
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ilham Maulana
library-app-django
Commits
9797a30f
Commit
9797a30f
authored
Aug 06, 2024
by
Ilham Maulana
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: shift to not use drf
parent
50ec5484
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
43 deletions
+0
-43
permissions.py
api/auth/permissions.py
+0
-43
No files found.
api/auth/permissions.py
deleted
100644 → 0
View file @
50ec5484
from
django.contrib.auth.models
import
User
from
rest_framework.permissions
import
IsAuthenticated
from
rest_framework.authtoken.models
import
Token
class
IsStaffUser
(
IsAuthenticated
):
def
has_permission
(
self
,
request
,
view
):
header
=
request
.
headers
.
get
(
"Authorization"
)
token
=
header
.
split
(
" "
)[
1
]
verified_token
=
None
try
:
verified_token
=
Token
.
objects
.
get
(
key
=
token
)
except
Token
.
DoesNotExist
:
return
False
return
bool
(
header
is
not
None
and
verified_token
is
not
None
and
verified_token
.
user
.
is_staff
)
class
IsNotStaffUser
(
IsAuthenticated
):
def
has_permission
(
self
,
request
,
view
):
header
=
request
.
headers
.
get
(
"Authorization"
)
token
=
header
.
split
(
" "
)[
1
]
verified_token
=
None
try
:
verified_token
=
Token
.
objects
.
get
(
key
=
token
)
except
Token
.
DoesNotExist
:
return
False
return
bool
(
header
is
not
None
and
verified_token
is
not
None
and
not
verified_token
.
user
.
is_staff
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment