mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
feat: WIP mail verification flow
This commit is contained in:
+31
-16
@@ -1,25 +1,34 @@
|
||||
package user
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ID uint32 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Email string `json:"email"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
ID uint32 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Email string `json:"email"`
|
||||
IsVerified bool `gorm:"default=false;not null"`
|
||||
VerificationCode string `gorm:"unique;not null"`
|
||||
VerificationExpiration time.Time `gorm:"not null"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func FromApi(
|
||||
username string,
|
||||
password string,
|
||||
email string,
|
||||
verificationCode string,
|
||||
) User {
|
||||
return User{
|
||||
Username: username,
|
||||
Password: password,
|
||||
Email: email,
|
||||
Username: username,
|
||||
Password: password,
|
||||
Email: email,
|
||||
IsVerified: false,
|
||||
VerificationCode: verificationCode,
|
||||
VerificationExpiration: time.Now().Add(2 * time.Hour),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,15 +37,21 @@ func FromDb(
|
||||
username string,
|
||||
password string,
|
||||
email string,
|
||||
isVerified bool,
|
||||
verificationCode string,
|
||||
verificationExpiration time.Time,
|
||||
createdAt time.Time,
|
||||
updatedAt time.Time,
|
||||
) User {
|
||||
return User{
|
||||
ID: id,
|
||||
Username: username,
|
||||
Password: password,
|
||||
Email: email,
|
||||
CreatedAt: createdAt,
|
||||
UpdatedAt: updatedAt,
|
||||
ID: id,
|
||||
Username: username,
|
||||
Password: password,
|
||||
Email: email,
|
||||
IsVerified: isVerified,
|
||||
VerificationCode: verificationCode,
|
||||
VerificationExpiration: verificationExpiration,
|
||||
CreatedAt: createdAt,
|
||||
UpdatedAt: updatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user