Skip to content

Commit 7f2ab83

Browse files
committed
Handle token refresh
1 parent bee76ab commit 7f2ab83

2 files changed

Lines changed: 6 additions & 27 deletions

File tree

src/authn/authn.ts

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -919,11 +919,6 @@ function checkCurrentUser () {
919919
}
920920
*/
921921

922-
// HACK this global variable exists to prevent authSession.handleIncomingRedirect
923-
// From being called twice. It would not be needed if it automatically redirected
924-
// by iteself. See https://github.com/inrupt/solid-client-authn-js/issues/514
925-
let checkingRedirect = false
926-
927922
/**
928923
* Retrieves currently logged in webId from either
929924
* defaultTestUser or SolidAuth
@@ -937,24 +932,11 @@ export async function checkUser<T> (
937932
/**
938933
* Handle a successful authentication redirect
939934
*/
940-
// HACK normally you wouldn't need to do a check to see if 'code' is in the
941-
// query, but it was removed from solid-client-authn-js
942-
// See https://github.com/inrupt/solid-client-authn-js/issues/421
943-
// Remove this after
944-
const authCode = new URL(window.location.href).searchParams.get('code')
945-
if (authCode && !checkingRedirect) {
946-
checkingRedirect = true
947-
// Being redirected after requesting a token
948-
await authSession
949-
.handleIncomingRedirect(window.location.href)
950-
// HACK solid-client-authn-js should automatically remove code and state
951-
// from the URL, but it doesn't, so we do it manually here
952-
// see https://github.com/inrupt/solid-client-authn-js/issues/514
953-
const newPageUrl = new URL(window.location.href)
954-
newPageUrl.searchParams.delete('code')
955-
newPageUrl.searchParams.delete('state')
956-
window.history.replaceState({}, '', newPageUrl.toString())
957-
}
935+
await authSession
936+
.handleIncomingRedirect({
937+
restorePreviousSession: true,
938+
url: window.location.href
939+
})
958940

959941
// Check to see if already logged in / have the WebID
960942
let me = defaultTestUser()

test/unit/acl/add-agent-buttons.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,7 @@ describe('When "Add App" button is clicked', () => {
165165
buttonToClick.click()
166166
})
167167
it('bar is simplified', () => {
168-
expect(bar.childNodes.length).toEqual(3)
169-
// Adds a third element to list, for reason I cannot understand - This does
170-
// not happen when I "manually test" it, ie run it in the browser
171-
// https://github.com/solid/solid-ui/issues/236
168+
expect(bar.childNodes.length).toEqual(2)
172169
})
173170
it('Bar still contains the button that was clicked', () => {
174171
expect(getButtonName(bar.childNodes[0])).toEqual(barButtons[buttonIndex])

0 commit comments

Comments
 (0)