pvanand commited on
Commit
2b0154f
·
verified ·
1 Parent(s): 4ebb821

Update static/auth.html

Browse files
Files changed (1) hide show
  1. static/auth.html +39 -0
static/auth.html CHANGED
@@ -51,6 +51,9 @@
51
  <input type="password" id="loginPassword" placeholder="Password">
52
  <button onclick="login()">Log In</button>
53
 
 
 
 
54
  <div id="message"></div>
55
  </div>
56
 
@@ -91,6 +94,42 @@
91
  console.error(error);
92
  });
93
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  </script>
95
  </body>
96
  </html>
 
51
  <input type="password" id="loginPassword" placeholder="Password">
52
  <button onclick="login()">Log In</button>
53
 
54
+ <h2>Email Verification</h2>
55
+ <button onclick="sendVerificationEmail()">Send Verification Email</button>
56
+
57
  <div id="message"></div>
58
  </div>
59
 
 
94
  console.error(error);
95
  });
96
  }
97
+
98
+ async function sendVerificationEmail() {
99
+ try {
100
+ const result = await account.createVerification(
101
+ 'https://pvanand-specialized-agents.hf.space/auth' // url
102
+ );
103
+ document.getElementById('message').innerText = 'Verification email sent! Please check your inbox.';
104
+ console.log(result);
105
+ } catch (error) {
106
+ document.getElementById('message').innerText = 'Failed to send verification email: ' + error.message;
107
+ console.error(error);
108
+ }
109
+ }
110
+
111
+ // Function to complete verification (to be called on the redirect page)
112
+ async function completeVerification() {
113
+ const urlParams = new URLSearchParams(window.location.search);
114
+ const userId = urlParams.get('userId');
115
+ const secret = urlParams.get('secret');
116
+
117
+ if (userId && secret) {
118
+ try {
119
+ const result = await account.updateVerification(userId, secret);
120
+ document.getElementById('message').innerText = 'Email verified successfully!';
121
+ console.log(result);
122
+ } catch (error) {
123
+ document.getElementById('message').innerText = 'Verification failed: ' + error.message;
124
+ console.error(error);
125
+ }
126
+ }
127
+ }
128
+
129
+ // Call completeVerification if on the redirect page
130
+ if (window.location.pathname === '/auth') {
131
+ completeVerification();
132
+ }
133
  </script>
134
  </body>
135
  </html>