Request object

This commit is contained in:
Eden Kirin
2024-02-06 16:21:00 +01:00
parent 75cded4054
commit 4d9759c093
17 changed files with 194 additions and 1210 deletions

45
app/data/users.go Normal file
View File

@ -0,0 +1,45 @@
package data
import "fiber-sessions/app/types"
var dbUsers map[string]types.User = map[string]types.User{
"pero-uuid": {
Id: "pero-uuid",
Username: "pero",
Password: "pero",
FirstName: "Pero",
LastName: "Perić",
},
"mirko-uuid": {
Id: "mirko-uuid",
Username: "mirko",
Password: "mirko",
FirstName: "Mirko",
LastName: "Mirković",
},
}
type usersStorage struct {
}
var UsersStorage = usersStorage{}
func (u usersStorage) GetUserById(id string) *types.User {
user, ok := dbUsers[id]
if ok {
return &user
}
return nil
}
func (u usersStorage) AuthUser(ident string, password string) *types.User {
for _, user := range dbUsers {
if user.Username == ident {
if user.Password == password {
return &user
}
break
}
}
return nil
}