feat: password reset #32

This commit is contained in:
Florian Sylvain
2024-06-14 13:46:39 +02:00
parent 727418c8e6
commit e4c2230b64
16 changed files with 527 additions and 64 deletions
+3
View File
@@ -5,8 +5,11 @@ import "GoCMS/domain/user"
type IUserRepository interface {
Get(id uint32) (user.User, error)
GetByUsername(username string) (user.User, error)
GetByEmail(email string) (user.User, error)
GetAll() []user.User
Create(user user.User) (user.User, error)
Delete(id uint32) error
UpdateVerificationStatus(userId uint32, isVerified bool) (user.User, error)
UpdatePassword(userId uint32, password string) (user.User, error)
UpdatePasswordResetCode(userId uint32, code string) (user.User, error)
}
+5 -5
View File
@@ -5,11 +5,11 @@ import (
)
type Image struct {
ID uint32
Path string
PostID uint32
CreatedAt time.Time
UpdatedAt time.Time
ID uint32 `json:"id"`
Path string `json:"path"`
PostID uint32 `json:"post_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func FromDB(id uint32, path string, postId uint32, createdAt time.Time, updatedAt time.Time) Image {
+8 -3
View File
@@ -8,10 +8,11 @@ type User struct {
ID uint32 `json:"id"`
Username string `json:"username"`
Password string `json:"password"`
PasswordResetCode string `json:"password_reset_code"`
Email string `json:"email"`
IsVerified bool `gorm:"default=false;not null"`
VerificationCode string `gorm:"unique;not null"`
VerificationExpiration time.Time `gorm:"not null"`
IsVerified bool `json:"is_verified"`
VerificationCode string `json:"verification_code"`
VerificationExpiration time.Time `json:"verification_expiration"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
@@ -19,6 +20,7 @@ type User struct {
func FromApi(
username string,
password string,
passwordResetCode string,
email string,
verificationCode string,
) User {
@@ -26,6 +28,7 @@ func FromApi(
return User{
Username: username,
Password: password,
PasswordResetCode: passwordResetCode,
Email: email,
IsVerified: false,
VerificationCode: verificationCode,
@@ -37,6 +40,7 @@ func FromDb(
id uint32,
username string,
password string,
passwordResetCode string,
email string,
isVerified bool,
verificationCode string,
@@ -48,6 +52,7 @@ func FromDb(
ID: id,
Username: username,
Password: password,
PasswordResetCode: passwordResetCode,
Email: email,
IsVerified: isVerified,
VerificationCode: verificationCode,