Skip to content

Be 03/04/07/feat(forget password) forgot, set password, and migration #13

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 7 commits into
base: development
Choose a base branch
from

Conversation

Kocannn
Copy link
Collaborator

@Kocannn Kocannn commented May 12, 2025

  • add migration + seeding with goose combine with cobra command
    usage migrate

  • go run main.go migrate:create name_migration // for create new file migration

  • go run main.go migrate:up // for up migration

  • go run main.go migrate:down // for down migration
    usage for seeding

  • go run main.go seed:create name_seed // for create new file seed

  • go run main.go seed:up // run seeding file

  • add feature to reset password

Kocannn added 6 commits May 6, 2025 20:25
- Implement forgot password handler to generate reset token and link
- Add reset password form to validate and update user password
- Create HTML templates for reset password and email confirmation
- Update routes to include forgot and reset password endpoints
- Add usecase methods for token verification and password reset
Add reset password functionality across repository, usecase, and handler
layers. This includes:

- Repository method to update user password in the database.
- Usecase logic to verify token, hash password, and call repository.
- HTTP handler to handle reset password requests.

Also updated the domain model to include token and password fields in
ForgotPassword struct and added the necessary interface methods.

BREAKING CHANGE: The reset password endpoint now requires a token and
password in the request body.
- Updated `ForgotPassword` use case to pass reset link to the email
template.
- Fixed email template rendering using `html/template` package.
- Adjusted reset link to point to the correct frontend URL.
- Improved error handling for email sending process.

This ensures users receive a functional reset password link in their
email.
Added new migration commands `migrate:create`, `migrate:up`, and
`migrate:down` using the goose library. Updated dependencies for
cobra and pflag to their latest versions. Removed unused imports
and legacy migration code.

BREAKING CHANGE: The `dbMigrate` command has been replaced with
new migration commands.
- Updated `ForgotPassword` to use frontend base URL for reset link.
- Added email and password validation in `ResetPassword` handler.
- Introduced `ConfirmPassword` field in `ForgotPassword` struct.
- Removed unused `ShowResetPasswordForm` and related assets.
- Added seeding commands (`seed:create`, `seed:up`, `seed:down`).
- Modified token generation to accept custom expiration time.
- Updated migration command to include table prefix.
- Fixed token validation logic to correctly handle used tokens.
- Improved GORM queries by using pointer semantics for better
performance.
- Enhanced error logging with `WithError` for better debugging context.
- Removed redundant `Model()` call in the initial token query.
- Improved code readability with named variables and consistent
formatting.

These changes enhance code clarity, maintainability, and runtime
efficiency.
@Kocannn Kocannn force-pushed the be-03/04/07/feat(forget-password)-forgot&set-password branch from f7b8830 to 1d7778b Compare May 12, 2025 09:30
@Kocannn Kocannn closed this May 12, 2025
@Kocannn Kocannn reopened this May 12, 2025
@Kocannn Kocannn closed this May 12, 2025
@Kocannn Kocannn reopened this May 12, 2025
@Kocannn Kocannn force-pushed the be-03/04/07/feat(forget-password)-forgot&set-password branch 3 times, most recently from 7bf0c4d to daf75ac Compare May 12, 2025 10:47
- Updated `cmd.go` to remove unused `seedDown` command.
- Adjusted `migrate.go` commands to align with `goose` CLI changes.
- Added new database migration files for `users`, `logout`, `events`,
  `registration_events`, `event_pays`, `event_speakers`, `event_tags`,
  `images`, and `testing` tables.
- Ensured proper foreign key constraints and sequence handling.

These changes improve database schema management and command usability.
@Kocannn Kocannn force-pushed the be-03/04/07/feat(forget-password)-forgot&set-password branch from daf75ac to fae1f49 Compare May 13, 2025 03:33
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.

1 participant