Skip to content

Feature/change account details 29 - #91

Merged
ShazeelAli merged 8 commits into
mainfrom
feature/change-account-details-29
Jul 23, 2026
Merged

Feature/change account details 29#91
ShazeelAli merged 8 commits into
mainfrom
feature/change-account-details-29

Conversation

@Toxsuh

@Toxsuh Toxsuh commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Issues

Closes #59
I know the branch is opened as 29 not 59 but the ticket is actually 59 my apologies

Description

  • Loosened the update access rule on users collection so a logged-in user can update their own row
  • Added a server action updateAccount in userDashboard page that re-verifies the current password via payload.login() before applying any change, then calls payload.update() with the requesting user's access context
  • Edits to userDashboard page for account detail changing
  • Wrapped the form in a client component UserAccountForm, uses useActionState for success/error handling and pending state
  • Footer also adjusted, no longer has negative padding and encroaches on site space for smaller pages

Checklist

  • Make sure you are requesting to pull a feature/fix branch (right side). Don't request the main branch!
  • Make sure you are making a pull request against the main branch (left side). Also you should start your branch off main branch.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added the necessary documentation (if appropriate).

How To Review

Users collection to check if access handling is ok
then changes to userDashboard and finally the UserAccountForm component

Notes

  • We don't have email verification, nor is our email form actually unique in the users collection. While users can't switch to an already existing email (blocked by code in userDashboard), they can make new accounts with the same email. (I think)
  • Error message on duplicate emails is Payload's default validation message, instead of our own message. Currently it says something like "Value must be unique" instead of "This email is already linked to an account".
  • Similarly, the error on current-password verification only comes up as "Incorrect password" instead of the actually valid error such as "Too many logins in a short amount of time. Please try later" etc etc.

@ShazeelAli ShazeelAli left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Still need to double check functionalty fully but seems good, just make the requested change if able

Comment thread app/(frontend)/userDashboard/page.tsx Outdated
await payload.update({ collection: 'users', id: user.id, data, user })
revalidatePath('/userDashboard')
return { status: 'success', message: 'Account updated.' }
} catch (err: any) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you try using something like this for the error catch rather than err:any

catch (err) {
if (err instanceof Error) {
return { status: 'error', message: err.message }
}
return { status: 'error', message: 'An unexpected error occurred' }
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed to add bucket error handling :D

@Toxsuh
Toxsuh requested a review from ShazeelAli July 22, 2026 08:13

@ShazeelAli ShazeelAli left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice changes

@ShazeelAli
ShazeelAli merged commit 79063bf into main Jul 23, 2026
1 check passed
@ShazeelAli
ShazeelAli deleted the feature/change-account-details-29 branch July 23, 2026 00:07
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.

Changing Account Details Logic

2 participants