|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>Account Activation</title> |
| 7 | + <style> |
| 8 | + body { |
| 9 | + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; |
| 10 | + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); |
| 11 | + margin: 0; |
| 12 | + padding: 0; |
| 13 | + min-height: 100vh; |
| 14 | + display: flex; |
| 15 | + justify-content: center; |
| 16 | + align-items: center; |
| 17 | + } |
| 18 | + |
| 19 | + .container { |
| 20 | + background: white; |
| 21 | + border-radius: 15px; |
| 22 | + box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1); |
| 23 | + padding: 40px; |
| 24 | + width: 100%; |
| 25 | + max-width: 500px; |
| 26 | + text-align: center; |
| 27 | + } |
| 28 | + |
| 29 | + .logo { |
| 30 | + font-size: 28px; |
| 31 | + font-weight: bold; |
| 32 | + color: #667eea; |
| 33 | + margin-bottom: 30px; |
| 34 | + } |
| 35 | + |
| 36 | + .icon { |
| 37 | + font-size: 64px; |
| 38 | + margin-bottom: 20px; |
| 39 | + color: #667eea; |
| 40 | + } |
| 41 | + |
| 42 | + h1 { |
| 43 | + color: #333; |
| 44 | + margin-bottom: 20px; |
| 45 | + font-size: 24px; |
| 46 | + } |
| 47 | + |
| 48 | + .description { |
| 49 | + color: #666; |
| 50 | + margin-bottom: 30px; |
| 51 | + line-height: 1.6; |
| 52 | + } |
| 53 | + |
| 54 | + .btn { |
| 55 | + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); |
| 56 | + color: white; |
| 57 | + padding: 15px 30px; |
| 58 | + border: none; |
| 59 | + border-radius: 8px; |
| 60 | + font-size: 16px; |
| 61 | + font-weight: 600; |
| 62 | + cursor: pointer; |
| 63 | + transition: transform 0.2s; |
| 64 | + width: 100%; |
| 65 | + margin-top: 20px; |
| 66 | + } |
| 67 | + |
| 68 | + .btn:hover { |
| 69 | + transform: translateY(-2px); |
| 70 | + } |
| 71 | + |
| 72 | + .btn:disabled { |
| 73 | + opacity: 0.6; |
| 74 | + cursor: not-allowed; |
| 75 | + transform: none; |
| 76 | + } |
| 77 | + |
| 78 | + .alert { |
| 79 | + padding: 15px; |
| 80 | + border-radius: 8px; |
| 81 | + margin-bottom: 20px; |
| 82 | + font-weight: 500; |
| 83 | + display: none; |
| 84 | + } |
| 85 | + |
| 86 | + .alert-success { |
| 87 | + background: #d4edda; |
| 88 | + color: #155724; |
| 89 | + border: 1px solid #c3e6cb; |
| 90 | + } |
| 91 | + |
| 92 | + .alert-error { |
| 93 | + background: #f8d7da; |
| 94 | + color: #721c24; |
| 95 | + border: 1px solid #f5c6cb; |
| 96 | + } |
| 97 | + |
| 98 | + .loading { |
| 99 | + display: none; |
| 100 | + margin-top: 20px; |
| 101 | + } |
| 102 | + |
| 103 | + .spinner { |
| 104 | + border: 2px solid #f3f3f3; |
| 105 | + border-top: 2px solid #667eea; |
| 106 | + border-radius: 50%; |
| 107 | + width: 20px; |
| 108 | + height: 20px; |
| 109 | + animation: spin 1s linear infinite; |
| 110 | + display: inline-block; |
| 111 | + margin-right: 10px; |
| 112 | + } |
| 113 | + |
| 114 | + @keyframes spin { |
| 115 | + 0% { transform: rotate(0deg); } |
| 116 | + 100% { transform: rotate(360deg); } |
| 117 | + } |
| 118 | + </style> |
| 119 | +</head> |
| 120 | +<body> |
| 121 | + <div class="container"> |
| 122 | + <div class="logo">🛍️ Hypex eCommerce</div> |
| 123 | + |
| 124 | + <div class="icon">✅</div> |
| 125 | + |
| 126 | + <h1>Account Activation</h1> |
| 127 | + |
| 128 | + <div class="description"> |
| 129 | + Welcome! Click the button below to activate your account and start shopping. |
| 130 | + </div> |
| 131 | + |
| 132 | + <div id="messages" class="alert"></div> |
| 133 | + |
| 134 | + <form id="activationForm" method="post" action="/auth/activate/"> |
| 135 | + {% csrf_token %} |
| 136 | + <input type="hidden" name="uid" value="{{ uid }}"> |
| 137 | + <input type="hidden" name="token" value="{{ token }}"> |
| 138 | + |
| 139 | + <button type="submit" class="btn" id="activateBtn"> |
| 140 | + Activate Account |
| 141 | + </button> |
| 142 | + |
| 143 | + <div class="loading" id="loading"> |
| 144 | + <div class="spinner"></div> |
| 145 | + Activating your account... |
| 146 | + </div> |
| 147 | + </form> |
| 148 | + </div> |
| 149 | + |
| 150 | + <script> |
| 151 | + document.getElementById('activationForm').addEventListener('submit', async function(e) { |
| 152 | + e.preventDefault(); |
| 153 | + |
| 154 | + const formData = new FormData(this); |
| 155 | + const uid = formData.get('uid'); |
| 156 | + const token = formData.get('token'); |
| 157 | + const activateBtn = document.getElementById('activateBtn'); |
| 158 | + const loading = document.getElementById('loading'); |
| 159 | + const messages = document.getElementById('messages'); |
| 160 | + |
| 161 | + // Clear previous messages |
| 162 | + messages.style.display = 'none'; |
| 163 | + messages.className = 'alert'; |
| 164 | + |
| 165 | + // Show loading state |
| 166 | + activateBtn.disabled = true; |
| 167 | + loading.style.display = 'block'; |
| 168 | + |
| 169 | + try { |
| 170 | + const response = await fetch('/auth/activate/', { |
| 171 | + method: 'POST', |
| 172 | + headers: { |
| 173 | + 'Content-Type': 'application/json', |
| 174 | + 'X-CSRFToken': formData.get('csrfmiddlewaretoken') |
| 175 | + }, |
| 176 | + body: JSON.stringify({ uid, token }) |
| 177 | + }); |
| 178 | + |
| 179 | + if (response.ok || response.status === 204) { |
| 180 | + messages.className = 'alert alert-success'; |
| 181 | + messages.innerHTML = '🎉 Account activated successfully! Redirecting to login...'; |
| 182 | + messages.style.display = 'block'; |
| 183 | + |
| 184 | + // Redirect to login page after 2 seconds |
| 185 | + setTimeout(() => { |
| 186 | + window.location.href = '/admin/login/'; |
| 187 | + }, 2000); |
| 188 | + |
| 189 | + } else { |
| 190 | + const data = await response.json(); |
| 191 | + const errorMessage = data.detail || data.error || 'Activation failed. Please try again.'; |
| 192 | + messages.className = 'alert alert-error'; |
| 193 | + messages.innerHTML = `❌ ${errorMessage}`; |
| 194 | + messages.style.display = 'block'; |
| 195 | + } |
| 196 | + |
| 197 | + } catch (error) { |
| 198 | + console.error('Activation error:', error); |
| 199 | + messages.className = 'alert alert-error'; |
| 200 | + messages.innerHTML = '❌ Network error. Please check your connection and try again.'; |
| 201 | + messages.style.display = 'block'; |
| 202 | + } finally { |
| 203 | + // Hide loading state |
| 204 | + activateBtn.disabled = false; |
| 205 | + loading.style.display = 'none'; |
| 206 | + } |
| 207 | + }); |
| 208 | + </script> |
| 209 | +</body> |
| 210 | +</html> |
0 commit comments