-
Notifications
You must be signed in to change notification settings - Fork 32
/
user.go
51 lines (43 loc) · 1.15 KB
/
user.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package user
import (
"context"
"time"
"github.com/raystack/frontier/pkg/metadata"
)
type State string
func (s State) String() string {
return string(s)
}
const (
Enabled State = "enabled"
Disabled State = "disabled"
)
type Repository interface {
GetByID(ctx context.Context, id string) (User, error)
GetByEmail(ctx context.Context, email string) (User, error)
GetByIDs(ctx context.Context, userIds []string) ([]User, error)
GetByName(ctx context.Context, name string) (User, error)
Create(ctx context.Context, user User) (User, error)
List(ctx context.Context, flt Filter) ([]User, error)
UpdateByID(ctx context.Context, toUpdate User) (User, error)
UpdateByName(ctx context.Context, toUpdate User) (User, error)
UpdateByEmail(ctx context.Context, toUpdate User) (User, error)
Delete(ctx context.Context, id string) error
SetState(ctx context.Context, id string, state State) error
}
type User struct {
ID string
Name string
Email string
State State
Avatar string
Title string
Metadata metadata.Metadata
CreatedAt time.Time
UpdatedAt time.Time
}
type AccessPair struct {
User User
On string
Can []string
}