Skip to content

Commit

Permalink
Switch authenticator to use the whoami service
Browse files Browse the repository at this point in the history
  • Loading branch information
markpatton committed Apr 2, 2024
1 parent d84ac72 commit 638b3a0
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions app/authenticators/http-only.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ export default class HttpOnly extends Base {
*/
restore(data) {
return new RSVP.Promise((resolve, reject) => {
if (window.location.pathname === '/app/auth-callback') {
return reject('Could not restore session.');
}
if (!this._validateData(data)) {
return reject('Could not restore session.');
}
Expand All @@ -35,7 +32,7 @@ export default class HttpOnly extends Base {
* @public
*/
async authenticate() {
const url = `${window.location.origin}/authenticated`;
const url = `/user/whoami`;

let response = await fetch(url);

Expand All @@ -61,16 +58,16 @@ export default class HttpOnly extends Base {

async _validateData(data) {
// see https://tools.ietf.org/html/rfc6749#section-4.2.2
if (isEmpty(data) || isEmpty(data.user.id)) return false;
if (isEmpty(data) || isEmpty(data.id)) return false;

const url = `${window.location.origin}/authenticated`;
const url = `/user/whoami`;

let response = await fetch(url);

if (response.ok) {
const refreshedData = await response.json();

return data.user.id === refreshedData.user.id;
return data.id === refreshedData.id;
} else {
return false;
}
Expand Down

0 comments on commit 638b3a0

Please sign in to comment.