Remove 'user' from AppContext

This commit is contained in:
Alex Gleason 2024-05-14 14:24:48 -05:00
parent a061c248bd
commit 45b766af4d
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 1 additions and 4 deletions

View File

@ -96,8 +96,6 @@ interface AppEnv extends HonoEnv {
signer?: NostrSigner; signer?: NostrSigner;
/** NIP-98 signed event proving the pubkey is owned by the user. */ /** NIP-98 signed event proving the pubkey is owned by the user. */
proof?: NostrEvent; proof?: NostrEvent;
/** User associated with the pubkey, if any. */
user?: User;
/** Store */ /** Store */
store: NStore; store: NStore;
}; };

View File

@ -34,9 +34,8 @@ type UserRole = 'user' | 'admin';
/** Require the user to prove their role before invoking the controller. */ /** Require the user to prove their role before invoking the controller. */
function requireRole(role: UserRole, opts?: ParseAuthRequestOpts): AppMiddleware { function requireRole(role: UserRole, opts?: ParseAuthRequestOpts): AppMiddleware {
return withProof(async (c, proof, next) => { return withProof(async (_c, proof, next) => {
const user = await findUser({ pubkey: proof.pubkey }); const user = await findUser({ pubkey: proof.pubkey });
c.set('user', user);
if (user && matchesRole(user, role)) { if (user && matchesRole(user, role)) {
await next(); await next();