-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathverify-auth.sh
More file actions
executable file
Β·185 lines (164 loc) Β· 5.3 KB
/
Copy pathverify-auth.sh
File metadata and controls
executable file
Β·185 lines (164 loc) Β· 5.3 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/bash
# Authentication System Verification Script
# Tests that all required files and configurations are in place
echo "π Tenchat Authentication System Verification"
echo "=================================================="
echo ""
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check counter
checks_passed=0
checks_failed=0
# Function to check file exists
check_file() {
if [ -f "$1" ]; then
echo -e "${GREEN}β${NC} $2"
((checks_passed++))
return 0
else
echo -e "${RED}β${NC} $2 - Missing: $1"
((checks_failed++))
return 1
fi
}
# Function to check env variable
check_env() {
if grep -q "^$1=" .env 2>/dev/null || grep -q "^$1=" .env.local 2>/dev/null; then
echo -e "${GREEN}β${NC} $2"
((checks_passed++))
return 0
else
echo -e "${YELLOW}β ${NC} $2 - Not found in .env or .env.local"
((checks_failed++))
return 1
fi
}
# Check directory structure
echo "π Checking Directory Structure..."
check_file "src/contexts/AppwriteContext.tsx" "AppwriteContext exists"
check_file "src/components/auth/auth-modal.tsx" "Auth Modal exists"
check_file "src/App.tsx" "App.tsx exists"
check_file "src/lib/appwrite/config/client.ts" "Appwrite client config exists"
echo ""
# Check documentation
echo "π Checking Documentation..."
check_file "AUTH_FIX_SUMMARY.md" "Fix Summary documentation"
check_file "AUTH_TESTING_GUIDE.md" "Testing Guide documentation"
check_file "AUTH_IMPROVEMENTS_COMPLETE.md" "Complete improvements doc"
check_file "AUTH_QUICK_REFERENCE.md" "Quick Reference card"
echo ""
# Check environment variables
echo "π Checking Environment Variables..."
check_env "VITE_APPWRITE_ENDPOINT" "Appwrite Endpoint"
check_env "VITE_APPWRITE_PROJECT_ID" "Appwrite Project ID"
check_env "VITE_WEB3_FUNCTION_ID" "Web3 Function ID"
echo ""
# Check node modules
echo "π¦ Checking Dependencies..."
if [ -d "node_modules" ]; then
echo -e "${GREEN}β${NC} node_modules installed"
((checks_passed++))
if [ -d "node_modules/appwrite" ]; then
version=$(node -p "require('./node_modules/appwrite/package.json').version" 2>/dev/null)
if [ ! -z "$version" ]; then
echo -e "${GREEN}β${NC} Appwrite SDK installed (v$version)"
((checks_passed++))
fi
else
echo -e "${RED}β${NC} Appwrite SDK not found"
((checks_failed++))
fi
else
echo -e "${RED}β${NC} node_modules not found - Run 'npm install'"
((checks_failed++))
fi
echo ""
# Check build
echo "π¨ Checking Build..."
if [ -d "dist" ]; then
echo -e "${GREEN}β${NC} Build directory exists"
((checks_passed++))
if [ -f "dist/index.html" ]; then
echo -e "${GREEN}β${NC} Build artifacts present"
((checks_passed++))
else
echo -e "${YELLOW}β ${NC} Build may be outdated - Run 'npm run build'"
fi
else
echo -e "${YELLOW}β ${NC} No build found - Run 'npm run build'"
fi
echo ""
# Try to verify build works
echo "βοΈ Testing Build Command..."
if npm run build > /tmp/auth-verify-build.log 2>&1; then
echo -e "${GREEN}β${NC} Build command succeeded"
((checks_passed++))
else
echo -e "${RED}β${NC} Build command failed - Check /tmp/auth-verify-build.log"
((checks_failed++))
fi
echo ""
# Check key code patterns
echo "π Checking Critical Code Patterns..."
# Check createSession call
if grep -q "createSession({" src/contexts/AppwriteContext.tsx; then
echo -e "${GREEN}β${NC} Correct createSession API call"
((checks_passed++))
else
echo -e "${RED}β${NC} createSession may be using wrong API"
((checks_failed++))
fi
# Check forceRefreshAuth exists
if grep -q "forceRefreshAuth" src/contexts/AppwriteContext.tsx; then
echo -e "${GREEN}β${NC} forceRefreshAuth method present"
((checks_passed++))
else
echo -e "${RED}β${NC} forceRefreshAuth method missing"
((checks_failed++))
fi
# Check debug panel in App.tsx
if grep -q "import.meta.env.DEV" src/App.tsx; then
echo -e "${GREEN}β${NC} Development debug panel code present"
((checks_passed++))
else
echo -e "${YELLOW}β ${NC} Debug panel may be missing"
((checks_failed++))
fi
# Check console.log statements
if grep -q "console.log('Checking authentication" src/contexts/AppwriteContext.tsx; then
echo -e "${GREEN}β${NC} Authentication logging present"
((checks_passed++))
else
echo -e "${YELLOW}β ${NC} Logging may be incomplete"
fi
echo ""
echo "=================================================="
echo "π Verification Results"
echo "=================================================="
echo -e "${GREEN}β Passed:${NC} $checks_passed checks"
echo -e "${RED}β Failed:${NC} $checks_failed checks"
echo ""
if [ $checks_failed -eq 0 ]; then
echo -e "${GREEN}π All checks passed! Authentication system is ready.${NC}"
echo ""
echo "Next steps:"
echo " 1. npm run dev # Start development server"
echo " 2. Open browser and test authentication"
echo " 3. Check console logs for auth flow"
echo " 4. Verify debug panel appears (dev mode only)"
echo ""
exit 0
else
echo -e "${YELLOW}β οΈ Some checks failed. Please review the issues above.${NC}"
echo ""
echo "Common fixes:"
echo " - Run 'npm install' if dependencies are missing"
echo " - Create .env file with required variables"
echo " - Run 'npm run build' to create build artifacts"
echo " - Check file paths if files are missing"
echo ""
exit 1
fi