forked from TryGhost/Headline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom-debesloguearte.hbs
105 lines (104 loc) · 3.08 KB
/
custom-debesloguearte.hbs
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Required | {{@site.title}}</title>
<style>
.ns {display: none}
body {
margin: 0;
background: #f5f5f5;
font-family: 'Open Sans', sans-serif;
min-height: 100vh;
display: grid;
place-items: center;
}
.login-container {
max-width: 550px;
background: #fff;
padding: 2rem 1.5rem;
border-radius: 15px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
h1 { text-align: center; }
p { line-height: 1.5rem; margin: 3rem auto;}
.actions {
display: flex;
flex-direction: column;
gap: 0.5rem;
justify-content: center;
align-items: center;
}
.primary {
display: inline-block;
width: fit-content;
background: #39f933;
color: #fff;
padding: 0.5rem 1rem;
border-radius: 10px;
text-decoration: none;
font-size: 1.2rem;
}
</style>
<noscript>
<style>
.login-container {
display: none;
}
.ns {
display: block;
}
</style>
</noscript>
</head>
<body>
<div class="ns">
<p>You must be a member to access the forum. Log in to {{@site.title}} before continuing to the forum.</p>
</div>
<div class="login-container">
<h1>Login Required</h1>
<p>You must be a member (it's free!) of {{@site.title}} to access the forum. Click the button below to log in.</p>
<div class="actions">
<a class="primary" data-portal>Log In</a>
<a class="secondary" href="#/">Access Forum</a>
</div>
</div>
<div class="logged-in-container" hidden>
<p>Logging you in, please wait...</p>
</div>
</body>
<script>
const loginWrapper = document.querySelector('.login-container');
const loggedInWrapper = document.querySelector('.logged-in-container');
const primaryButton = document.querySelector('.primary');
const secondaryButton = document.querySelector('.secondary');
const discourseOnGhostUrl = 'https://criptonautas.co/ghost/api/external_discourse_on_ghost';
const searchParams = new URLSearchParams(window.location.search);
const redirectUrl = new URL('./sso', discourseOnGhostUrl);
redirectUrl.searchParams.set('sso', searchParams.get('sso'));
redirectUrl.searchParams.set('sig', searchParams.get('sig'));
redirectUrl.searchParams.set('signedIn', 'true');
if (searchParams.get('success') === 'true' && searchParams.has('sso') && searchParams.has('sig')) {
window.window.location.href = redirectUrl.href;
loginWrapper.hidden = true;
loggedInWrapper.hidden = false;
} else {
secondaryButton.href = redirectUrl.href;
primaryButton.addEventListener(
'click', () => window.addEventListener('focusout', swapButtons, {once: true}), {once: true}
);
}
function swapButtons() {
const secondaryText = primaryButton.textContent;
primaryButton.href = secondaryButton.href;
secondaryButton.dataset.portal = true;
delete primaryButton.dataset.portal;
secondaryButton.removeAttribute('href');
primaryButton.textContent = secondaryButton.textContent;
secondaryButton.textContent = secondaryText;
primaryButton.focus();
}
</script>
</html>