From 17c1cb92fca326923ea2d91a9cdb1326e76aadb0 Mon Sep 17 00:00:00 2001 From: Warren Parad Date: Wed, 13 Dec 2023 23:48:02 +0100 Subject: [PATCH] Block registration usage when the user isn't logged in. --- src/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/index.js b/src/index.js index 190b6bd..97e09d5 100644 --- a/src/index.js +++ b/src/index.js @@ -168,6 +168,11 @@ class LoginClient { async registerDevice(options = { name: '' }) { const userIdentity = await this.getUserIdentity(); + if (!userIdentity) { + const e = Error('User must be logged to configure user profile data.'); + e.code = 'NotLoggedIn'; + throw e; + } const userId = userIdentity.sub; // https://developer.mozilla.org/en-US/docs/Web/API/CredentialsContainer/create