-
Notifications
You must be signed in to change notification settings - Fork 42
fix(ui): handle auth/session errors using HTTP semantics #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e974dbd
413bfc0
28c6284
08c325f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,7 +203,13 @@ export class LoginComponent implements OnInit, AfterViewInit { | |
| }, | ||
| err => { | ||
| this.resetCaptcha(); | ||
| this.confirmationService.alert(err, 'error'); | ||
| const message = [err?.error?.errorMessage, err?.message].find( | ||
| msg => !!msg | ||
| ); | ||
| this.confirmationService.alert( | ||
| message || 'Login request failed. Please try again.', | ||
| 'error' | ||
| ); | ||
|
Comment on lines
+206
to
+212
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π― Functional Correctness | π Major | β‘ Quick win π§© Analysis chainπ Script executed: #!/bin/bash
set -euo pipefail
echo "Repository files around login component:"
git ls-files | grep -E '(^|/)login\.component\.ts$|package\.json$|src/app/app-modules/login' | head -100
echo
echo "Login component excerpt:"
if [ -f src/app/app-modules/login/login.component.ts ]; then
nl -ba src/app/app-modules/login/login.component.ts | sed -n '1,280p'
else
echo "login.component.ts not found"
fi
echo
echo "Search for status-specific login message handling:"
rg -n "400|401|403|404|409|500|HttpErrorResponse|errorMessage|confirmationService\.alert|Login request failed" src/app/app-modules/login src || trueRepository: PSMRI/MMU-UI Length of output: 459 π Script executed: #!/bin/bash
set -euo pipefail
echo "Login component excerpt (wc + sed):"
wc -l src/app/app-modules/login/login.component.ts
sed -n '1,280p' src/app/app-modules/login/login.component.ts
echo
echo "Search for status-specific login handling:"
rg -n "400|401|403|404|409|500|HttpErrorResponse|errorMessage|confirmationService\.alert|Login request failed|status" src/app/app-modules/login src || true
echo
echo "Package script hints:"
python3 -c "
import json
from pathlib import Path
p=Path('package.json')
if p.exists():
d=json.loads(p.read_text())
for k,v in d.get('scripts',{}).items():
if 'lint' in k or 'test' in k or 'build' in k:
print(f'{k}: {v}')
"Repository: PSMRI/MMU-UI Length of output: 50369 π Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
p = Path('src/app/app-modules/login/login.component.ts')
text = p.read_text()
print(f'file_exists={p.exists()} lines={text.count(chr(10))+1}')
for start,end in [(1,80),(180,230)]:
print(f'\n--- {start}-{end} ---')
for i,line in enumerate(text.splitlines(),1):
if start <= i <= end:
print(f'{i:4}: {line}')
print('\n--- targeted occurrences in login component ---')
for needle in ['confirmationService.alert', 'Login request failed', 'errorMessage', 'HttpErrorResponse', 'status', '400', '401', '403', '404', '409', '500']:
matches = []
for i,line in enumerate(text.splitlines(),1):
if needle in line:
matches.append(i)
print(f'{needle}: {matches[:40]}' if len(matches)<=40 else f'{needle}: {matches[:40]} ... count={len(matches)}')
PY
echo
echo "Login spec status/message snippets:"
python3 - <<'PY'
from pathlib import Path
p = Path('src/app/app-modules/login/login.component.spec.ts')
text = p.read_text()
for needle in ['Login request failed', 'errorMessage', 'HttpErrorResponse', 'status', '400', '401', '403', '404', '409', '500', 'confirmationService.alert']:
matches = [i for i,line in enumerate(text.splitlines(),1) if needle in line]
print(f'{needle}: first {matches[:10]} count={len(matches)} total_lines={text.count(chr(10))+1}')
PYRepository: PSMRI/MMU-UI Length of output: 6101 Map The error block at π€ Prompt for AI Agents |
||
| } | ||
| ); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π©Ί Stability & Availability | π‘ Minor | β‘ Quick win
π§© Analysis chain
π Script executed:
Repository: PSMRI/MMU-UI
Length of output: 50369
π Script executed:
Repository: PSMRI/MMU-UI
Length of output: 10916
Handle session validation errors on login.
AuthGuardredirects to/loginon validation failures whilesessionStorage.isAuthenticatedremains set.LoginComponent.ngOnInit()then subscribes tovalidateSessionKey()with no error handler, so the invalid session repeats the failing request and propagates an unhandled RxJS error. Clear the staleisAuthenticatedstate for failed/expired sessions, or handle the validation error inLoginComponent; do not clear credentials for transient server errors.π€ Prompt for AI Agents