|
| 1 | +<% content_for :title, "Chrome Extension Token" %> |
| 2 | + |
| 3 | +<div class="flex items-center justify-center py-12 px-4"> |
| 4 | + <div class="bg-white p-10 rounded-xl shadow-lg text-center max-w-lg w-full"> |
| 5 | + <% if params[:redirect_uri].present? %> |
| 6 | + <!-- Modern flow: automatic redirect via chrome.identity.launchWebAuthFlow --> |
| 7 | + <div class="text-5xl text-blue-500 mb-5 animate-pulse">⟳</div> |
| 8 | + <h1 class="text-gray-800 mb-5 text-2xl font-semibold">Redirecting...</h1> |
| 9 | + <p class="text-gray-600"> |
| 10 | + Authentication successful! Redirecting back to your extension...<br> |
| 11 | + <span class="text-sm mt-2 inline-block">This window will close automatically.</span> |
| 12 | + </p> |
| 13 | + <% else %> |
| 14 | + <!-- Legacy flow: content script captures token --> |
| 15 | + <div class="text-5xl text-green-500 mb-5">✓</div> |
| 16 | + <h1 class="text-gray-800 mb-5 text-2xl font-semibold">Authentication Successful</h1> |
| 17 | + |
| 18 | + <p class="mb-5">Your user email for the Chrome extension:</p> |
| 19 | + |
| 20 | + <div class="bg-gray-50 border-2 border-dashed border-gray-300 rounded-lg p-5 my-5 break-all font-mono text-sm min-h-15 flex items-center justify-center"> |
| 21 | + <div id="token-display" data-token="<%= current_user&.email %>" class="text-sky-600 font-semibold"> |
| 22 | + <%= current_user&.email || 'No email available. Please try again.' %> |
| 23 | + </div> |
| 24 | + </div> |
| 25 | + |
| 26 | + <div class="text-gray-600 text-sm leading-relaxed mt-5"> |
| 27 | + <strong>Instructions:</strong><br> |
| 28 | + Your email above will be automatically captured by your Chrome extension.<br> |
| 29 | + You can safely close this window after the email is captured. |
| 30 | + </div> |
| 31 | + <% end %> |
| 32 | + |
| 33 | + <!-- Debug info (remove in production) --> |
| 34 | + <div class="bg-gray-100 border border-gray-300 rounded p-3 mt-3 text-xs text-gray-600"> |
| 35 | + <strong>Debug:</strong> User: <%= current_user&.email || 'NOT AUTHENTICATED' %> | |
| 36 | + Session: <%= session[:user_id] || 'NO SESSION' %> | |
| 37 | + Redirect URI: <%= params[:redirect_uri].present? ? 'Yes' : 'No' %> |
| 38 | + </div> |
| 39 | + </div> |
| 40 | +</div> |
| 41 | + |
| 42 | +<% unless params[:redirect_uri].present? %> |
| 43 | +<script> |
| 44 | + console.log('Auth page loaded - email should be captured by Chrome extension content script'); |
| 45 | + console.log('Email in data-token:', document.getElementById('token-display')?.getAttribute('data-token')); |
| 46 | + |
| 47 | + // Redirect to root after extension captures token (5 seconds) |
| 48 | + setTimeout(() => { |
| 49 | + console.log('Redirecting to root...'); |
| 50 | + window.location.href = '/'; |
| 51 | + }, 5000); |
| 52 | +</script> |
| 53 | +<% end %> |
0 commit comments