Skip to content

Commit 3390a7d

Browse files
authored
Merge branch 'develop' into master
2 parents ae99c39 + a1810d3 commit 3390a7d

File tree

4 files changed

+30
-68
lines changed

4 files changed

+30
-68
lines changed

default-templates/new-account/index.html

Lines changed: 11 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -58,76 +58,25 @@ <h1>Data</h1>
5858
<div class="col-md-12">
5959
<h1>Apps</h1>
6060
<div class="list-group">
61-
<a href="https://databox.me/apps/friends/" target="_blank" class="list-group-item">
62-
<span class="lead">Friends</span>
63-
</a>
64-
<a href="https://github.com/solid/solid-apps" target="_blank" class="list-group-item">
65-
<span class="lead">More Apps</span>
61+
<a href="https://github.com/solid/userguide" target="_blank" class="list-group-item">
62+
<span class="lead">Getting started with Solid and Data Browser</span>
6663
</a>
6764
</div>
6865
</div>
6966
</section>
70-
<footer>| <a target="_blank" href="https://github.com/solid/userguide">Getting started with solid and data browser</a> |</footer>
7167
</div>
72-
</body>
7368
<script src="/common/js/solid-auth-client.bundle.js"></script>
7469
<script type="text/javascript">
75-
const popupUri = window.location.origin + '/common/popup.html'
76-
const stateData = {
77-
session: null
78-
}
79-
const state = new Proxy(stateData, {
80-
set: (obj, prop, value) => {
81-
obj[prop] = value
82-
render()
83-
}
84-
})
85-
86-
function main() {
87-
// Render the session state
88-
SolidAuthClient
89-
.currentSession()
90-
.then(saveSession)
91-
.then(render)
92-
93-
// Add event listeners
94-
const actionButton = sessionActionButton()
95-
actionButton.addEventListener('click', takeSessionAction)
96-
}
97-
98-
function saveSession(session) {
99-
state.session = session
100-
return session
101-
}
70+
const button = document.getElementById('session-action')
71+
let loggedIn = false
10272

103-
function takeSessionAction() {
104-
const { session } = state
105-
const loggedIn = !!session
106-
if (loggedIn) {
107-
SolidAuthClient
108-
.logout()
109-
.then(saveSession)
110-
} else {
111-
SolidAuthClient
112-
.popupLogin({ popupUri })
113-
.then(saveSession)
114-
}
115-
}
116-
117-
function render() {
118-
const { session } = state
119-
const actionButton = sessionActionButton()
120-
if (!session) {
121-
actionButton.innerText = 'Log in'
122-
} else {
123-
actionButton.innerText = 'Log out'
124-
}
125-
}
126-
127-
function sessionActionButton() {
128-
return document.getElementById('session-action')
129-
}
73+
solid.auth.trackSession(session => {
74+
loggedIn = !!session
75+
button.innerText = loggedIn ? 'Log out' : 'Log in'
76+
})
13077

131-
document.addEventListener('DOMContentLoaded', main)
78+
button.addEventListener('click', () =>
79+
loggedIn ? solid.auth.logout() : solid.auth.popupLogin())
13280
</script>
81+
</body>
13382
</html>

default-views/auth/login-required.hbs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<title>Log in</title>
77
<link rel="stylesheet" href="/common/css/bootstrap.min.css">
8-
<script src="/common/js/solid-auth-client.bundle.js"></script>
98
</head>
109
<body>
1110
<div class="container">
@@ -20,17 +19,16 @@
2019
<button class="btn btn-primary" onclick="register()">Register</button>
2120
</div>
2221
</div>
22+
<script src="/common/js/solid-auth-client.bundle.js"></script>
2323
<script>
2424
async function login() {
25-
// Log in through the popup
26-
const popupUri = '/common/popup.html'
27-
const session = await SolidAuthClient.popupLogin({ popupUri })
25+
const session = await solid.auth.popupLogin()
2826
if (session) {
2927
// Make authenticated request to the server to establish a session cookie
30-
const { status } = await SolidAuthClient.fetch(location)
28+
const { status } = await solid.auth.fetch(location)
3129
if (status === 401) {
3230
alert(`Invalid login.\n\nDid you set ${session.idp} as your OIDC provider in your profile ${session.webId}?`);
33-
await SolidAuthClient.logout();
31+
await solid.auth.logout()
3432
}
3533
// Now that we have a cookie, reload to display the authenticated page
3634
location.reload()

lib/api/authn/webid-oidc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ function middleware (oidc) {
9494
['/common/js/', 'solid-auth-client/dist-lib/solid-auth-client.bundle.js.map']
9595
]
9696
authAssets.map(([path, file]) => routeResolvedFile(router, path, file))
97+
// Redirect for .well-known login popup location
98+
router.get('/.well-known/solid/login',
99+
(req, res) => res.redirect('/common/popup.html'))
97100

98101
// Initialize the OIDC Identity Provider routes/api
99102
// router.get('/.well-known/openid-configuration', discover.bind(provider))

package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)