Skip to content

Commit

Permalink
Require user to be logged in to update devices.
Browse files Browse the repository at this point in the history
  • Loading branch information
wparad committed Dec 13, 2023
1 parent c749941 commit ab8b5f1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ class LoginClient {
}

async getDevices() {
await this.waitForUserSession();

try {
const token = await this.ensureToken();
const deviceResult = await this.httpClient.get('/session/devices', this.enableCredentials, { Authorization: token && `Bearer ${token}` });
Expand All @@ -144,8 +142,6 @@ class LoginClient {
}

async deleteDevice(deviceId) {
await this.waitForUserSession();

try {
const token = await this.ensureToken();
await this.httpClient.delete(`/session/devices/${encodeURIComponent(deviceId)}`, this.enableCredentials, { Authorization: token && `Bearer ${token}` });
Expand All @@ -156,6 +152,12 @@ class LoginClient {
}

async openUserConfigurationScreen(options = { redirectUrl: null, startPage: 'Profile' }) {
if (!this.getUserIdentity()) {
const e = Error('User must be logged to configure user profile data.');
e.code = 'NotLoggedIn';
throw e;
}

const userConfigurationScreenUrl = new URL('/settings', this.hostUrl);
userConfigurationScreenUrl.searchParams.set('client_id', this.settings.applicationId);
userConfigurationScreenUrl.searchParams.set('redirect_uri', options && options.redirectUrl || window.location.href);
Expand All @@ -164,8 +166,6 @@ class LoginClient {
}

async registerDevice(options = { name: '' }) {
await this.waitForUserSession();

const userIdentity = await this.getUserIdentity();
const userId = userIdentity.sub;

Expand Down Expand Up @@ -423,7 +423,7 @@ class LoginClient {
}

if (!this.getUserIdentity()) {
const e = Error('User must be logged into to unlink an account.');
const e = Error('User must be logged in to unlink an account.');
e.code = 'NotLoggedIn';
throw e;
}
Expand Down

0 comments on commit ab8b5f1

Please sign in to comment.