Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ECE651_Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chris Li
ECE651_Backend
Commits
bbf55456
Commit
bbf55456
authored
1 year ago
by
Chris Li
Browse files
Options
Downloads
Patches
Plain Diff
Bugfix: fixed delete user not work.
parent
935b628b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/api/auth.py
+7
-10
7 additions, 10 deletions
core/api/auth.py
core/api/bill.py
+1
-1
1 addition, 1 deletion
core/api/bill.py
core/urls.py
+2
-2
2 additions, 2 deletions
core/urls.py
with
10 additions
and
13 deletions
core/api/auth.py
+
7
−
10
View file @
bbf55456
...
...
@@ -7,7 +7,7 @@ from django.contrib.auth.models import User
from
django.shortcuts
import
render
from
django.urls
import
reverse
from
rest_framework
import
generics
,
status
,
serializers
,
HTTP_HEADER_ENCODING
,
permissions
from
rest_framework.decorators
import
api_view
,
authentication_classes
,
permission_classes
from
rest_framework.decorators
import
api_view
,
authentication_classes
from
rest_framework.response
import
Response
from
knox.auth
import
TokenAuthentication
from
knox.models
import
AuthToken
...
...
@@ -180,17 +180,14 @@ def validate_token(request):
return
Response
({
'
valid
'
:
'
false
'
})
@api_view
([
'
DELETE
'
])
@authentication_classes
([])
# @permission_classes([permissions.IsAuthenticated])
def
delete_account
(
request
):
try
:
authenticator
=
TokenAuthentication
()
user
,
auth_token
=
authenticator
.
authenticate
(
request
)
if
user
and
auth_token
:
class
DeleteAccountAPI
(
generics
.
GenericAPIView
):
permission_classes
=
(
permissions
.
IsAuthenticated
,)
def
delete
(
self
,
request
):
user
=
self
.
request
.
user
if
user
:
user
.
delete
()
return
Response
({
'
msg
'
:
'
Delete successfully.
'
})
except
:
return
Response
({
'
msg
'
:
'
Failed to delete this account.
'
},
status
=
status
.
HTTP_401_UNAUTHORIZED
)
...
...
This diff is collapsed.
Click to expand it.
core/api/bill.py
+
1
−
1
View file @
bbf55456
...
...
@@ -12,7 +12,7 @@ class BillListCreate(mixins.ListModelMixin, mixins.CreateModelMixin, generics.Ge
# authentication.SessionAuthentication,
# authentication.TokenAuthentication
# ]
#
permission_classes = (permissions.IsAuthenticated,)
permission_classes
=
(
permissions
.
IsAuthenticated
,)
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
return
self
.
list
(
request
,
*
args
,
**
kwargs
)
...
...
This diff is collapsed.
Click to expand it.
core/urls.py
+
2
−
2
View file @
bbf55456
...
...
@@ -2,7 +2,7 @@ from django.urls import path, include
from
knox
import
views
as
knox_views
from
rest_framework
import
routers
from
core.api.auth
import
RegisterAPI
,
LoginAPI
,
AppleLogin
,
GoogleLogin
,
FacebookLogin
,
validate_token
,
d
elete
_a
ccount
,
verify_user_and_activate
from
core.api.auth
import
RegisterAPI
,
LoginAPI
,
AppleLogin
,
GoogleLogin
,
FacebookLogin
,
validate_token
,
D
elete
A
ccount
API
,
verify_user_and_activate
from
core.api.password
import
ChangePasswordView
from
core.api.profile
import
ProfileViewSet
from
core.api.coupon
import
CouponViewSet
...
...
@@ -24,7 +24,7 @@ urlpatterns += [
path
(
'
api/auth/google
'
,
GoogleLogin
.
as_view
(),
name
=
'
google_login
'
),
path
(
'
api/auth/facebook
'
,
FacebookLogin
.
as_view
(),
name
=
'
facebook_login
'
),
path
(
'
api/auth/validate-token
'
,
validate_token
,
name
=
'
validate-token
'
),
path
(
'
api/auth/delete-account
'
,
d
elete
_a
ccount
,
name
=
'
delete-account
'
),
path
(
'
api/auth/delete-account
'
,
D
elete
A
ccount
API
.
as_view
()
,
name
=
'
delete-account
'
),
# passwd
path
(
'
api/change-password
'
,
ChangePasswordView
.
as_view
(),
name
=
'
change-password
'
),
path
(
'
api/password_reset/
'
,
include
(
'
django_rest_passwordreset.urls
'
,
namespace
=
'
password_reset
'
)),
...
...
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