Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
V
vidai
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
SexHackMe
vidai
Commits
cb5d5078
Commit
cb5d5078
authored
Oct 06, 2025
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix get_user_api_tokens to handle missing 'name' column
parent
817b4e0e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
6 deletions
+25
-6
database.py
vidai/database.py
+25
-6
No files found.
vidai/database.py
View file @
cb5d5078
...
@@ -372,6 +372,11 @@ def init_db(conn) -> None:
...
@@ -372,6 +372,11 @@ def init_db(conn) -> None:
FOREIGN KEY (user_id) REFERENCES users (id)
FOREIGN KEY (user_id) REFERENCES users (id)
)
)
'''
)
'''
)
# Add name column if it doesn't exist (for migration)
try
:
cursor
.
execute
(
'ALTER TABLE user_api_tokens ADD COLUMN name TEXT'
)
except
sqlite3
.
OperationalError
:
pass
# Column already exists
# Insert default admin user if not exist
# Insert default admin user if not exist
import
hashlib
import
hashlib
...
@@ -1150,14 +1155,28 @@ def get_user_api_tokens(user_id: int) -> List[Dict[str, Any]]:
...
@@ -1150,14 +1155,28 @@ def get_user_api_tokens(user_id: int) -> List[Dict[str, Any]]:
"""Get all API tokens for a user."""
"""Get all API tokens for a user."""
conn
=
get_db_connection
()
conn
=
get_db_connection
()
cursor
=
conn
.
cursor
()
cursor
=
conn
.
cursor
()
try
:
cursor
.
execute
(
'''
cursor
.
execute
(
'''
SELECT id, name, created_at, last_used, active
SELECT id, name, created_at, last_used, active
FROM user_api_tokens
FROM user_api_tokens
WHERE user_id = ? ORDER BY created_at DESC
WHERE user_id = ? ORDER BY created_at DESC
'''
,
(
user_id
,))
'''
,
(
user_id
,))
except
sqlite3
.
OperationalError
:
# Fallback if 'name' column doesn't exist
cursor
.
execute
(
'''
SELECT id, created_at, last_used, active
FROM user_api_tokens
WHERE user_id = ? ORDER BY created_at DESC
'''
,
(
user_id
,))
rows
=
cursor
.
fetchall
()
rows
=
cursor
.
fetchall
()
conn
.
close
()
conn
.
close
()
return
[
dict
(
row
)
for
row
in
rows
]
tokens
=
[]
for
row
in
rows
:
token_dict
=
dict
(
row
)
if
'name'
not
in
token_dict
:
token_dict
[
'name'
]
=
'Unnamed Token'
# Default name
tokens
.
append
(
token_dict
)
return
tokens
def
delete_user_api_token
(
user_id
:
int
,
token_id
:
int
)
->
bool
:
def
delete_user_api_token
(
user_id
:
int
,
token_id
:
int
)
->
bool
:
...
...
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