-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuser.go
49 lines (43 loc) · 1.54 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
package eduboard
import (
"gopkg.in/mgo.v2/bson"
"net/url"
"time"
)
type User struct {
ID bson.ObjectId `json:"id" bson:"_id"`
Name string `json:"name" bson:"name"`
Surname string `json:"surname" bson:"surname"`
Email string `json:"email" bson:"email"`
PasswordHash string `json:"password" bson:"password"`
SessionID string `json:"sessionID" bson:"sessionID"`
SessionExpires time.Time `json:"sessionExpires" bson:"sessionExpires"`
Courses []string `json:"courses" bson:"courses"`
CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
Picture url.URL `json:"profilePicture" bson:"profilePicture"`
}
type UserFinder interface {
FindMembers(members []string) (error, []User)
}
type UserRepository interface {
Store(user *User) error
Find(id string) (error, User)
FindMany(query bson.M) ([]User, error)
FindByEmail(email string) (error, User)
FindBySessionID(sessionID string) (error, User)
IsIDValid(id string) bool
UpdateSessionID(user User) (error, User)
UserFinder
}
type UserService interface {
CreateUser(u *User, password string) (error, User)
GetUser(id string) (error, User)
GetAllUsers() ([]User, error)
GetMyCourses(id string, cS CourseManyFinder, cEMF CourseEntryManyFinder) (error, []Course)
UserAuthenticationProvider
}
type UserAuthenticationProvider interface {
Login(email string, password string) (error, User)
Logout(sessionID string) error
CheckAuthentication(sessionID string) (err error, userID string)
}