mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
feat: users & authentication implementation
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package gateways
|
||||
|
||||
import . "GohCMS2/domain/user"
|
||||
|
||||
type IUserRepository interface {
|
||||
Get(id uint32) (User, error)
|
||||
GetByUsername(username string) (User, error)
|
||||
GetAll() []User
|
||||
Create(user User) (User, error)
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package user
|
||||
|
||||
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"`
|
||||
}
|
||||
|
||||
func FromApi(
|
||||
username string,
|
||||
password string,
|
||||
email string,
|
||||
) User {
|
||||
return User{
|
||||
Username: username,
|
||||
Password: password,
|
||||
Email: email,
|
||||
}
|
||||
}
|
||||
|
||||
func FromDb(
|
||||
id uint32,
|
||||
username string,
|
||||
password string,
|
||||
email string,
|
||||
createdAt time.Time,
|
||||
updatedAt time.Time,
|
||||
) User {
|
||||
return User{
|
||||
ID: id,
|
||||
Username: username,
|
||||
Password: password,
|
||||
Email: email,
|
||||
CreatedAt: createdAt,
|
||||
UpdatedAt: updatedAt,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user