mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 05:45:59 +01:00
Implement token generation check in CloudManager and update user token handling in saveChangesAPIAccess. Ensure users are prompted to reset their password if a valid API token is not present when enabling API access.
This commit is contained in:
@@ -43,6 +43,10 @@ class CloudManager:
|
|||||||
|
|
||||||
def verifyLogin(self, request):
|
def verifyLogin(self, request):
|
||||||
try:
|
try:
|
||||||
|
# Check if token needs to be generated
|
||||||
|
if self.admin.token == 'TOKEN_NEEDS_GENERATION':
|
||||||
|
return 0, self.ajaxPre(0, 'API token needs to be generated. Please reset your password to generate a valid API token.')
|
||||||
|
|
||||||
if request.META['HTTP_AUTHORIZATION'] == self.admin.token:
|
if request.META['HTTP_AUTHORIZATION'] == self.admin.token:
|
||||||
return 1, self.ajaxPre(1, None)
|
return 1, self.ajaxPre(1, None)
|
||||||
else:
|
else:
|
||||||
|
|||||||
BIN
to-do/Skjermbilde 2025-09-21 193540.png
Normal file
BIN
to-do/Skjermbilde 2025-09-21 193540.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 148 KiB |
@@ -99,6 +99,13 @@ def saveChangesAPIAccess(request):
|
|||||||
|
|
||||||
if access == "Enable":
|
if access == "Enable":
|
||||||
userAcct.api = 1
|
userAcct.api = 1
|
||||||
|
# When enabling API access, ensure the user has a proper token
|
||||||
|
# The token should be generated based on username:password format
|
||||||
|
# If no token exists, we'll need the user to reset their password
|
||||||
|
if not userAcct.token or userAcct.token == 'None' or userAcct.token == '':
|
||||||
|
# Token will be generated when user changes their password
|
||||||
|
# For now, set a placeholder that indicates API access is enabled but token needs generation
|
||||||
|
userAcct.token = 'TOKEN_NEEDS_GENERATION'
|
||||||
else:
|
else:
|
||||||
userAcct.api = 0
|
userAcct.api = 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user