Skip to content

Sadar0001/jwt-layer-implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image

Start Application & Create Test Users

  1. Run your Spring Boot application
  2. Go to http://localhost:8080/register
  3. Create two test users: o User 1: email: admin@test.com, password: admin123, role: ADMIN o User 2: email: user@test.com, password: user123, role: USER

Test Login/Logout Flow

  1. Click "Logout" button
  2. Should redirect to login page
  3. Login with admin@test.com / admin123
  4. Should redirect to dashboard showing ADMIN role

Test API Endpoints from Dashboard While logged in as ADMIN: • Click "Test User Endpoint" → Should see: "Hello admin@test.com! You have USER access..." • Click "Test Admin Endpoint" → Should see: "Hello ADMIN admin@test.com!..."

Test Session Persistence

  1. Login successfully
  2. Close browser tab
  3. Open new tab, go to http://localhost:8080/dashboard
  4. Should still be logged in (JWT cookie working)

Test Token Expiration

  1. Login successfully
  2. Wait 1 hour (or change JWT expiration to 1 minute for testing)
  3. Try API calls → Should fail/redirect to login

Test Login Page

  1. Go to http://localhost:8080/login
  2. Enter credentials: o Email: admin@test.com o Password: admin123
  3. Click "Login" button
  4. Should redirect to dashboard if successful

Verify JWT Cookie is Set

  1. After successful login, press F12 (Developer Tools)
  2. Go to "Application" or "Storage" tab
  3. Click "Cookies" → http://localhost:8080
  4. Should see a cookie named "jwt" with a long token value
diagram-export-21-09-2025-22_30_59 02-flowchart

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published