mirror of
https://github.com/HeyPuter/puter.git
synced 2026-08-24 15:07:17 +00:00
Sign in first in the requestPermission fixture's email flow on the web
In env=web the site has no auth token, so whoami threw 401 immediately and the email button appeared to do nothing. Sign in via popup first, matching the real third-party flow; env=app already has a token and is unaffected.
This commit is contained in:
@@ -49,9 +49,15 @@
|
||||
}
|
||||
waitForPuter();
|
||||
|
||||
// Requests to see the user's email; needs whoami (env=app only).
|
||||
// Requests to see the user's email. Needs whoami, which needs an
|
||||
// auth token: in env=app the GUI injects one, but in env=web the
|
||||
// site must sign in first (the realistic third-party flow).
|
||||
document.getElementById('req-email-perm').addEventListener('click', async () => {
|
||||
try {
|
||||
if (!puter.authToken) {
|
||||
log('perm:email:signing-in');
|
||||
await puter.auth.signIn();
|
||||
}
|
||||
const whoami = await puter.auth.whoami();
|
||||
const granted = await puter.ui.requestPermission({
|
||||
permission: `user:${whoami.uuid}:email:read`,
|
||||
|
||||
Reference in New Issue
Block a user