-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_error_handling.php
More file actions
44 lines (34 loc) · 1.7 KB
/
demo_error_handling.php
File metadata and controls
44 lines (34 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
declare(strict_types=1);
/**
* Demonstration script for handling expired refresh tokens
* This script shows how the improved error handling works
*/
require_once 'vendor/autoload.php';
echo "CSAS Authorize - Refresh Token Error Handling Demo\n";
echo "=================================================\n\n";
// This script demonstrates the improved error handling for expired refresh tokens
echo "The following improvements have been made:\n\n";
echo "1. Updated Token::refreshToken() method:\n";
echo " - Added try/catch block for IdentityProviderException\n";
echo " - Clears expired refresh token from database\n";
echo " - Provides clear error messages\n";
echo " - Throws RuntimeException with specific error code 24\n\n";
echo "2. Updated token.php UI:\n";
echo " - Catches RuntimeException with code 24 (expired refresh token)\n";
echo " - Redirects user to re-authorization page\n";
echo " - Shows informative message about token expiration\n\n";
echo "3. Added comprehensive test coverage:\n";
echo " - Tests for valid token refresh\n";
echo " - Tests for expired token handling\n";
echo " - Tests for missing refresh token scenarios\n";
echo " - Tests for token validation methods\n\n";
echo "Error Flow:\n";
echo "1. User clicks 'Refresh' button on expired token\n";
echo "2. Token::refreshToken() catches IdentityProviderException\n";
echo "3. Expired refresh token is cleared from database\n";
echo "4. RuntimeException with code 24 is thrown\n";
echo "5. token.php catches the exception\n";
echo "6. User is redirected to auth.php for re-authorization\n";
echo "7. Clear message explains what happened\n\n";
echo "This ensures a graceful user experience when refresh tokens expire.\n";