#!/bin/bash # Refresh Token Implementation Verification Script # This script verifies that the refresh token system is properly set up echo "========================================" echo "Refresh Token Implementation Verification" echo "========================================" echo "" # Colors GREEN='\033[0;32m' RED='\033[0;31m' YELLOW='\033[1;33m' NC='\033[0m' # No Color SUCCESS=0 FAILED=0 check_file() { if [ -f "$1" ]; then echo -e "${GREEN}✓${NC} $2" ((SUCCESS++)) else echo -e "${RED}✗${NC} $2 - File not found: $1" ((FAILED++)) fi } echo "1. Checking Core Files..." echo "----------------------------" check_file "src/modules/auth/entities/refresh-token.entity.ts" "RefreshToken Entity" check_file "src/modules/auth/repositories/refresh-token.repository.ts" "RefreshToken Repository" check_file "src/modules/auth/services/refresh-token.service.ts" "RefreshToken Service" check_file "src/modules/auth/dto/refresh-token.dto.ts" "RefreshToken DTO" echo "" echo "2. Checking Updated Files..." echo "----------------------------" check_file "src/modules/auth/auth.module.ts" "Auth Module" check_file "src/modules/auth/auth.service.ts" "Auth Service" check_file "src/modules/auth/auth.controller.ts" "Auth Controller" check_file "src/modules/auth/dto/auth-response.dto.ts" "Auth Response DTO" echo "" echo "3. Checking Migration..." echo "----------------------------" check_file "src/database/migrations/1736519000000-CreateRefreshTokensTable.ts" "Refresh Token Migration" echo "" echo "4. Checking Documentation..." echo "----------------------------" check_file "REFRESH_TOKEN_IMPLEMENTATION.md" "Implementation Guide" check_file "TESTING_REFRESH_TOKEN.md" "Testing Guide" check_file "OPTIONAL_SETUP.md" "Optional Setup Guide" check_file "REFRESH_TOKEN_SUMMARY.md" "Implementation Summary" echo "" echo "5. Checking Configuration..." echo "----------------------------" if grep -q "REFRESH_TOKEN_EXPIRY_DAYS" .env; then echo -e "${GREEN}✓${NC} Environment variables configured" ((SUCCESS++)) else echo -e "${RED}✗${NC} REFRESH_TOKEN_EXPIRY_DAYS not found in .env" ((FAILED++)) fi echo "" echo "6. Checking Code Updates..." echo "----------------------------" # Check if RefreshToken is imported in data-source.ts if grep -q "RefreshToken" src/database/data-source.ts; then echo -e "${GREEN}✓${NC} RefreshToken entity registered in data-source" ((SUCCESS++)) else echo -e "${RED}✗${NC} RefreshToken entity not registered in data-source" ((FAILED++)) fi # Check if auth-response.dto has refresh_token field if grep -q "refresh_token" src/modules/auth/dto/auth-response.dto.ts; then echo -e "${GREEN}✓${NC} AuthResponseDto includes refresh_token" ((SUCCESS++)) else echo -e "${RED}✗${NC} AuthResponseDto missing refresh_token field" ((FAILED++)) fi # Check if auth controller has new endpoints if grep -q "Post('refresh')" src/modules/auth/auth.controller.ts && \ grep -q "Post('logout')" src/modules/auth/auth.controller.ts && \ grep -q "Post('revoke-all')" src/modules/auth/auth.controller.ts; then echo -e "${GREEN}✓${NC} Auth controller has all new endpoints" ((SUCCESS++)) else echo -e "${RED}✗${NC} Auth controller missing endpoints" ((FAILED++)) fi echo "" echo "7. Build Verification..." echo "----------------------------" if npm run build > /dev/null 2>&1; then echo -e "${GREEN}✓${NC} Application builds successfully" ((SUCCESS++)) else echo -e "${RED}✗${NC} Build failed - check for compilation errors" ((FAILED++)) fi echo "" echo "========================================" echo "Verification Complete" echo "========================================" echo -e "Passed: ${GREEN}$SUCCESS${NC}" echo -e "Failed: ${RED}$FAILED${NC}" echo "" if [ $FAILED -eq 0 ]; then echo -e "${GREEN}✓ All checks passed! Refresh token system is ready.${NC}" echo "" echo "Next steps:" echo " 1. Run: npm run migration:run (if not already done)" echo " 2. Run: npm run start:dev" echo " 3. Test using: TESTING_REFRESH_TOKEN.md" echo "" exit 0 else echo -e "${RED}✗ Some checks failed. Please review the errors above.${NC}" echo "" exit 1 fi