Skip to content

Add AuthStatusView for user login and data management#326

Open
shiffiH wants to merge 1 commit intomainfrom
shiffiH-patch-4
Open

Add AuthStatusView for user login and data management#326
shiffiH wants to merge 1 commit intomainfrom
shiffiH-patch-4

Conversation

@shiffiH
Copy link
Copy Markdown
Collaborator

@shiffiH shiffiH commented Nov 9, 2025

Implement AuthStatusView for user authentication and data display.

Implement AuthStatusView for user authentication and data display.
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

Adds AuthStatusView, a PyQt6-based dashboard for user authentication and data table browsing with the following features:

  • Login form with username/password authentication via /auth/login endpoint
  • JWT token display with real-time expiration countdown
  • Dynamic table selection from environment variable TABLES_LIST
  • Table data loading and display with search/filter functionality
  • Extensive sip.isdeleted() checks to prevent crashes from deleted Qt widgets

Key Issues:

  • Missing PyJWT dependency in GUI/requirements.txt (line 3 imports jwt)
  • Authorization header will be malformed if API returns None for access_token (line 175)
  • Direct use of requests.post instead of self.api.http which has retry logic (line 169)

Confidence Score: 3/5

  • Safe to merge after fixing missing dependency and null token handling
  • Score reflects one critical issue (missing PyJWT dependency will cause runtime ImportError) and one logic bug (None token will create malformed auth header). The defensive sip.isdeleted() checks throughout show good Qt awareness. Style improvements recommended but not blocking.
  • GUI/src/vast/views/auth_status_view.py requires adding PyJWT to requirements.txt and fixing null token handling on line 175

Important Files Changed

File Analysis

Filename Score Overview
GUI/src/vast/views/auth_status_view.py 3/5 New PyQt6 dashboard for user authentication and table data viewing. Missing PyJWT dependency and has minor logic issue with None token handling.

Sequence Diagram

sequenceDiagram
    participant User
    participant AuthStatusView
    participant API
    participant Backend
    
    User->>AuthStatusView: Enter credentials & click Login
    AuthStatusView->>Backend: POST /auth/login (username, password)
    Backend-->>AuthStatusView: 200 OK (access_token, refresh_token)
    AuthStatusView->>AuthStatusView: Decode JWT to extract expiry
    AuthStatusView->>API: Update Authorization header
    AuthStatusView->>User: Display tokens & success message
    
    User->>AuthStatusView: Select table & click Load
    AuthStatusView->>Backend: GET /api/tables/{table_name}
    Backend-->>AuthStatusView: 200 OK (table data)
    AuthStatusView->>AuthStatusView: Normalize & populate table
    AuthStatusView->>User: Display data in QTableWidget
    
    User->>AuthStatusView: Type in search box
    AuthStatusView->>AuthStatusView: Filter cached data
    AuthStatusView->>User: Display filtered results
    
    loop Every 1 second
        AuthStatusView->>AuthStatusView: Calculate token expiry time
        AuthStatusView->>User: Update tooltip with remaining time
    end
Loading

1 file reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

@@ -0,0 +1,316 @@

from __future__ import annotations
import os, time, jwt, requests, json
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: jwt library (PyJWT) not in GUI/requirements.txt

Suggested change
import os, time, jwt, requests, json
import os, time, requests, json

Add PyJWT to requirements.txt or remove JWT decoding (lines 177-180)

try:
url = f"{self.api.base}/auth/login"
data = {"username": user, "password": password}
r = requests.post(url, data=data, timeout=10)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Uses requests.post directly instead of self.api.http which has retry logic, proper headers, and session management

Suggested change
r = requests.post(url, data=data, timeout=10)
r = self.api.http.post(url, data=data, timeout=10)

self.expiry_ts = payload.get("exp")
except Exception:
self.expiry_ts = None
msg_prefix = "✅ Access Token updated!\n\n" if old_token and self.access_token != old_token else ""
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Checks if token differs from old, but emoji will show even on first login when old_token is None

Comment on lines +173 to +175
self.access_token = js.get("access_token")
self.refresh_token = js.get("refresh_token")
self.api.http.headers.update({"Authorization": f"Bearer {self.access_token}"})
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: If access_token is None from the API response, the authorization header will contain the string "None"

Add null check before updating header

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant