Fix superadmin matching: case-insensitive username/email lookup
Azure AD returns mixed-case usernames (VadymSamoilenko) but superadmin was created with lowercase. Use LOWER() for matching. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c59db0e9fd
commit
f5cb1170bb
1 changed files with 5 additions and 2 deletions
|
|
@ -157,10 +157,13 @@ class Database:
|
|||
logger.error(f"Error creating test user: {e}")
|
||||
|
||||
def _create_superadmin(self, conn: sqlite3.Connection, email: str):
|
||||
"""Create or promote superadmin user."""
|
||||
"""Create or promote superadmin user (case-insensitive match)."""
|
||||
try:
|
||||
username = email.split('@')[0]
|
||||
cursor = conn.execute('SELECT id, role FROM users WHERE username = ? OR email = ?', (username, email))
|
||||
cursor = conn.execute(
|
||||
'SELECT id, role FROM users WHERE LOWER(username) = LOWER(?) OR LOWER(email) = LOWER(?)',
|
||||
(username, email),
|
||||
)
|
||||
row = cursor.fetchone()
|
||||
if row:
|
||||
if row['role'] != 'admin':
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue