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:
Nariman Jelveh
2026-07-25 15:50:39 -07:00
parent 70f829a905
commit dfeef56c90
@@ -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`,