这是indexloc提供的服务,不要输入任何密码
Skip to content

'Delete user' - BACK #152

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

hyunnbunt
Copy link
Contributor

  • Connect '/auth/self/deactivate-user' API request to a new module 'deactivateSelfUser'

Copy link

vercel bot commented Jul 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-plasmic-cms-i18n ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 7:48am
examples-react-email ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 7:48am

Copy link

github-actions bot commented Jul 24, 2025

Thank you for your submission, we really appreciate it! ❤️

Like many open-source projects, we ask that you sign our Individual Contributor License Agreement before we can accept your contribution. If you are contributing on behalf of a company, please contact us at help@plasmic.app to sign a Corporate Contributor License Agreement.

You can sign the individual CLA by posting a comment with the below text.


I have read, agree to, and hereby sign Plasmic's Individual Contributor License Agreement


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Copy link
Member

@jaslong jaslong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add a test for delete in routes.spec.ts

@@ -1318,6 +1318,10 @@ export function addMainAppServerRoutes(
sensitiveRateLimiter,
withNext(authRoutes.updateSelfPassword)
);
app.post(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use app.delete("/api/v1/auth/self") as the route

@@ -338,6 +338,22 @@ export async function updateSelfPassword(req: Request, res: Response) {
);
}

export async function deactivateSelfUser(req: Request, res: Response) {
const mgr = superDbMgr(req);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would allow anyone to delete anyone in the database. Only the currently logged in user should be able to delete themselves. You need to use checkUserIdIsSelf to get the user ID.

@@ -338,6 +338,22 @@ export async function updateSelfPassword(req: Request, res: Response) {
);
}

export async function deactivateSelfUser(req: Request, res: Response) {
const mgr = superDbMgr(req);
const email = req.body.email;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should not be a user identifier passed to the server, since the server already has access to the cookie that identifies the user.

Comment on lines 348 to 353
res.clearCookie("plasmic-observer");
// Must reset the session to prevent session fixation attacks, reset the CSRF
// token, etc.
if (req.session) {
await util.promisify(req.session.destroy.bind(req.session))();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just call doLogout instead. Can you also move the highlighted lines into the doLogout function?

@@ -338,6 +338,22 @@ export async function updateSelfPassword(req: Request, res: Response) {
);
}

export async function deactivateSelfUser(req: Request, res: Response) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to deleteSelf

Copy link
Member

@jaslong jaslong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I will merge this, no need to make the change in the comment

export async function deleteSelf(req: Request, res: Response) {
const mgr = userDbMgr(req);

const id = getUser(req, { allowUnverifiedEmail: true }).id;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you can call checkUserIdIsSelf() without an argument, it will return the current user ID of the DbMgr. So getUser should be unnecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants