-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth_callback.html
More file actions
68 lines (63 loc) · 2.23 KB
/
auth_callback.html
File metadata and controls
68 lines (63 loc) · 2.23 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MailLayer | Authenticating...</title>
<style>
body {
font-family: 'Inter', sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: #111;
color: white;
margin: 0;
}
.spinner {
border: 4px solid rgba(255, 255, 255, 0.1);
border-left-color: #e03616;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div style="text-align: center;">
<div class="spinner" style="margin: 0 auto 20px;"></div>
<p id="status">Completing authentication...</p>
</div>
<script>
(function() {
// Extract token from fragment or query string
const fragment = window.location.hash.substring(1);
const params = new URLSearchParams(fragment || window.location.search);
const token = params.get('access_token');
const error = params.get('error');
const state = params.get('state');
if (token) {
// Use state to identify provider (gmail or outlook)
const provider = state || 'gmail'; // Default to gmail for backward compatibility
window.opener.postMessage({
type: 'maillayer-auth-token',
token: token,
provider: provider
}, '*');
document.getElementById('status').innerText = 'Authenticated! Closing window...';
setTimeout(() => window.close(), 500);
} else if (error) {
document.getElementById('status').innerText = 'Error: ' + error;
setTimeout(() => window.close(), 3000);
} else {
document.getElementById('status').innerText = 'No token found.';
setTimeout(() => window.close(), 2000);
}
})();
</script>
</body>
</html>