Pepguy commited on
Commit
ec00e65
·
verified ·
1 Parent(s): 54ae71f

Update signing.html

Browse files
Files changed (1) hide show
  1. signing.html +143 -9
signing.html CHANGED
@@ -3,7 +3,7 @@
3
  <head>
4
  <meta charset="UTF-8" />
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Everyday Cats – Sign-in Confirmed</title>
7
  <style>
8
  body {
9
  background: #fffafc;
@@ -17,6 +17,10 @@
17
  text-align: center;
18
  margin: 0;
19
  }
 
 
 
 
20
  h1 {
21
  font-size: 1.8rem;
22
  margin-bottom: 0.5rem;
@@ -36,21 +40,151 @@
36
  color: white;
37
  cursor: pointer;
38
  transition: 0.2s;
 
 
39
  }
40
  button:hover {
41
- background: #FFB84D;
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
43
  </style>
44
  </head>
45
  <body>
46
- <h1>Sign-up Complete</h1>
47
- <p>Your Everyday Cats account is ready. You can now return to the app and <strong>Login</strong>.</p>
48
- <button onclick="openApp()"> Open </button>
 
 
 
 
49
 
50
- <script>
51
- const appPackage = "everydaydresscode"; // update with your actual Android package name
52
- function openApp() {
53
- window.location.href = `${appPackage}://`//`intent://#Intent;package=${appPackage};end`;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
55
  </script>
56
  </body>
 
3
  <head>
4
  <meta charset="UTF-8" />
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Everyday Cats – Sign-in</title>
7
  <style>
8
  body {
9
  background: #fffafc;
 
17
  text-align: center;
18
  margin: 0;
19
  }
20
+ .container {
21
+ max-width: 400px;
22
+ padding: 2rem;
23
+ }
24
  h1 {
25
  font-size: 1.8rem;
26
  margin-bottom: 0.5rem;
 
40
  color: white;
41
  cursor: pointer;
42
  transition: 0.2s;
43
+ width: 100%;
44
+ max-width: 280px;
45
  }
46
  button:hover {
47
+ background: #ffa833;
48
+ }
49
+ button:disabled {
50
+ opacity: 0.6;
51
+ cursor: not-allowed;
52
+ }
53
+ .error {
54
+ color: #d32f2f;
55
+ margin-top: 1rem;
56
+ font-size: 0.9rem;
57
+ }
58
+ .loading {
59
+ margin-top: 1rem;
60
+ opacity: 0.7;
61
  }
62
  </style>
63
  </head>
64
  <body>
65
+ <div class="container">
66
+ <h1 id="title">Welcome to Everyday Cats</h1>
67
+ <p id="message">Sign in with your Google account to continue</p>
68
+ <button id="authButton" onclick="handleAuth()">Sign in with Google</button>
69
+ <p class="loading" id="loading" style="display: none;">Processing...</p>
70
+ <p class="error" id="error"></p>
71
+ </div>
72
 
73
+ <!-- Firebase SDK -->
74
+ <script type="module">
75
+ import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js';
76
+ import { getAuth, signInWithPopup, GoogleAuthProvider, onAuthStateChanged } from 'https://www.gstatic.com/firebasejs/10.7.1/firebase-auth.js';
77
+
78
+ // Firebase configuration - REPLACE WITH YOUR CONFIG
79
+ const firebaseConfig = {
80
+ apiKey: "AIzaSyAJZ5UwyLo4b4L8_G7Nocw0nj7dhyBZ_yU",
81
+ authDomain: "cartpost-db-06.firebaseapp.com",
82
+ projectId: "cartpost-db-06",
83
+ storageBucket: "cartpost-db-06.firebasestorage.app",
84
+ messagingSenderId: "212802992706",
85
+ appId: "1:212802992706:web:2a32a453c42cbc3bdfcbdb",
86
+ measurementId: "G-JYWF6B9MVZ"
87
+
88
+ };
89
+
90
+ // Initialize Firebase
91
+ const app = initializeApp(firebaseConfig);
92
+ const auth = getAuth(app);
93
+ const provider = new GoogleAuthProvider();
94
+
95
+ const appScheme = "everydaydresscode"; // Your app's deep link scheme
96
+
97
+ // UI elements
98
+ const titleEl = document.getElementById('title');
99
+ const messageEl = document.getElementById('message');
100
+ const buttonEl = document.getElementById('authButton');
101
+ const loadingEl = document.getElementById('loading');
102
+ const errorEl = document.getElementById('error');
103
+
104
+ // Check if user is already signed in
105
+ onAuthStateChanged(auth, (user) => {
106
+ if (user) {
107
+ showSuccess(user);
108
+ }
109
+ });
110
+
111
+ // Handle authentication
112
+ window.handleAuth = async function() {
113
+ try {
114
+ buttonEl.disabled = true;
115
+ loadingEl.style.display = 'block';
116
+ errorEl.textContent = '';
117
+
118
+ const result = await signInWithPopup(auth, provider);
119
+ const user = result.user;
120
+ const credential = GoogleAuthProvider.credentialFromResult(result);
121
+ const token = await user.getIdToken();
122
+
123
+ showSuccess(user);
124
+
125
+ // Redirect to app with auth data
126
+ setTimeout(() => {
127
+ redirectToApp(token, user);
128
+ }, 2000);
129
+
130
+ } catch (error) {
131
+ console.error('Auth error:', error);
132
+ buttonEl.disabled = false;
133
+ loadingEl.style.display = 'none';
134
+
135
+ let errorMessage = 'Authentication failed. Please try again.';
136
+ if (error.code === 'auth/popup-closed-by-user') {
137
+ errorMessage = 'Sign-in cancelled. Please try again.';
138
+ } else if (error.code === 'auth/popup-blocked') {
139
+ errorMessage = 'Pop-up blocked. Please allow pop-ups and try again.';
140
+ }
141
+ errorEl.textContent = errorMessage;
142
+ }
143
+ };
144
+
145
+ /*
146
+ const myButton = document.getElementById('authButton');
147
+
148
+ myButton.addEventListener('click', function() {
149
+ alert('Hello from the button!');
150
+ });
151
+
152
+ */
153
+
154
+ function showSuccess(user) {
155
+ titleEl.textContent = 'Sign-in Complete';
156
+ messageEl.innerHTML = `Welcome, <strong>${user.displayName || user.email}</strong>! Redirecting to app...`;
157
+ buttonEl.textContent = 'Open App';
158
+ buttonEl.onclick = () => redirectToApp(null, user);
159
+ buttonEl.disabled = false;
160
+ loadingEl.style.display = 'none';
161
+ }
162
+
163
+ async function redirectToApp(token, user) {
164
+ // Get fresh token if not provided
165
+ if (!token) {
166
+ token = await user.getIdToken();
167
+ }
168
+
169
+ // Prepare user data
170
+ const userData = {
171
+ uid: user.uid,
172
+ email: user.email,
173
+ displayName: user.displayName,
174
+ photoURL: user.photoURL,
175
+ token: token
176
+ };
177
+
178
+ // Encode data for URL
179
+ const encodedData = encodeURIComponent(JSON.stringify(userData));
180
+
181
+ // Try to open the app with deep link
182
+ window.location.href = `${appScheme}://auth?data=${encodedData}`;
183
+
184
+ // Fallback: If app doesn't open in 2 seconds, show manual instructions
185
+ setTimeout(() => {
186
+ messageEl.innerHTML = 'If the app didn\'t open automatically, please open it manually.';
187
+ }, 2000);
188
  }
189
  </script>
190
  </body>