Skip to content

Commit

Permalink
Add login functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenVerborgh committed Sep 25, 2018
1 parent b614d0c commit 5c0dfa1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<h1>Profile viewer</h1>
<p id="login">
You are not logged in.
<button>Log in</button>
</p>
<p id="logout">
You are logged in as <span id="user"></span>.
Expand Down
12 changes: 11 additions & 1 deletion scripts/main.js
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
$('#logout').hide();
// Log the user in on click
const popupUri = 'popup.html';
$('#login button').click(() => solid.auth.popupLogin({ popupUri }));

// Update components to match the user's login status
solid.auth.trackSession(session => {
const loggedIn = !!session;
$('#login').toggle(!loggedIn);
$('#logout').toggle(loggedIn);
$('#user').text(session && session.webId);
});

0 comments on commit 5c0dfa1

Please sign in to comment.