-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_manager.go
37 lines (29 loc) · 878 Bytes
/
user_manager.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package user_manager
import (
"errors"
om "github.com/zhangminghui6106/delinkcious-0.5/pkg/object_model"
)
type UserManager struct {
userStore om.UserManager
}
func NewUserManager(userStore om.UserManager) (userManager om.UserManager, err error) {
if userStore == nil {
return nil, errors.New("user store can't be nil")
}
return &UserManager{userStore: userStore}, nil
}
func (m *UserManager) Register(user om.User) error {
if user.Name == "" {
return errors.New("invalid user name")
}
return m.userStore.Register(user)
}
func (m *UserManager) Login(username string, authToken string) (session string, err error) {
if username == "" {
return "", errors.New("username can't be empty")
}
return m.userStore.Login(username, authToken)
}
func (m *UserManager) Logout(username string, session string) error {
return m.userStore.Logout(username, session)
}