mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 19:53:21 +02:00
feat: password reset #32
This commit is contained in:
@@ -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,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
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user