Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions default-views/auth/login-tls.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,29 @@
{{> auth/auth-hidden-fields}}
</div>
</form>

<script type="text/javascript">
const button = document.getElementById('login-tls')
button.addEventListener('click', function(event) {
event.preventDefault()
fetch('/login/tls', { method: 'POST', credentials: 'include' })
.then(function(response) {
const webId = response.headers.get('user')
const idp = new URL(webId).origin
const session = { authType: 'WebID-TLS', webId, idp }
const authClientNamespace = 'solid-auth-client'
let authClientStore
try {
authClientStore = JSON.parse(localStorage.getItem(authClientNamespace) || '{}')
} catch (err) {
authClientStore = {}
}
authClientStore.session = session
localStorage.setItem(authClientNamespace, JSON.stringify(authClientStore))
return response
})
.then(function(response) {
window.location.href = response.url
})
})
</script>