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:
Master3395
2025-09-21 19:38:02 +02:00
parent 54da24dd55
commit 8b34833534
3 changed files with 11 additions and 0 deletions

View File

@@ -99,6 +99,13 @@ def saveChangesAPIAccess(request):
if access == "Enable":
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:
userAcct.api = 0