-
Notifications
You must be signed in to change notification settings - Fork 1
Fixing password flow #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing password flow #190
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -91,7 +91,39 @@ export function createServer() { | |||||
| return auth.handler(new Request(url, c.req.raw)); | ||||||
| } | ||||||
|
|
||||||
| app.post('/api/auth/password/set', (c) => proxyToAuth(c, '/api/auth/set-password')); | ||||||
| app.post('/api/auth/password/set', async (c) => { | ||||||
| try { | ||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||
| const { newPassword } = await c.req.json(); | ||||||
| await auth.api.setPassword({ | ||||||
| body: { newPassword }, | ||||||
| headers: c.req.raw.headers, | ||||||
| }); | ||||||
|
|
||||||
| const session = await auth.api.getSession({ | ||||||
| headers: c.req.raw.headers, | ||||||
| }); | ||||||
|
|
||||||
| if (session?.user?.email) { | ||||||
| await db | ||||||
| .update(schema.users) | ||||||
| .set({ status: 'verified', updatedAt: new Date() }) | ||||||
| .where(eq(schema.users.email, session.user.email)); | ||||||
| logger.info(`User status updated to verified for email: ${session.user.email}`); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove raw email from success logs. Line 111 logs a full email address, which introduces avoidable PII exposure in application logs. Proposed fix- logger.info(`User status updated to verified for email: ${session.user.email}`);
+ logger.info('User status updated to verified');📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| } else { | ||||||
| logger.warn( | ||||||
| 'Password set succeeded, but session or user email is missing. Skipped updating user status to verified.' | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
| return c.json({ success: true }); | ||||||
|
Joel-Joseph-George marked this conversation as resolved.
|
||||||
| } catch (err) { | ||||||
| logger.error('Failed to set password:', err); | ||||||
| return c.json( | ||||||
| { message: err instanceof Error ? err.message : 'Failed to set password' }, | ||||||
| 400 | ||||||
| ); | ||||||
| } | ||||||
| }); | ||||||
|
|
||||||
| // POST /api/auth/forget-password | ||||||
| app.post('/api/auth/forget-password', (c) => proxyToAuth(c, '/api/auth/request-password-reset')); | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial | ⚡ Quick win
Strengthen malformed-JSON test with a no-side-effect assertion.
After Line 145, assert
auth.api.setPasswordwas not called to lock in short-circuit behavior on parse failure.Proposed test addition
expect(res.status).toBe(400); const json = await res.json(); expect(json.message).toBeDefined(); + expect(auth.api.setPassword).not.toHaveBeenCalled();📝 Committable suggestion
🤖 Prompt for AI Agents