Skip to content

Commit

Permalink
Allow logging in with demo users in standard OTP dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
dfahlander committed Apr 6, 2024
1 parent 7131ade commit bdbbf96
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions addons/dexie-cloud/src/authentication/otpFetchTokenCallback.ts
Expand Up @@ -48,11 +48,20 @@ export function otpFetchTokenCallback(db: DexieCloudDB): FetchTokenCallback {
'Enter email address',
hints?.email
);
tokenRequest = {
email,
grant_type: 'otp',
scopes: ['ACCESS_DB'],
} satisfies OTPTokenRequest1;
if (/@demo.local$/.test(email)) {
tokenRequest = {
demo_user: email,
grant_type: 'demo',
scopes: ['ACCESS_DB'],
public_key
} satisfies DemoTokenRequest;
} else {
tokenRequest = {
email,
grant_type: 'otp',
scopes: ['ACCESS_DB'],
} satisfies OTPTokenRequest1;
}
}
const res1 = await fetch(`${url}/token`, {
body: JSON.stringify(tokenRequest),
Expand Down

0 comments on commit bdbbf96

Please sign in to comment.