auth/auth.go (raw)
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 |
package auth import ( //nilfm.cc/git/goldbug/cookie "time" ) type User struct { Name string Pass string Session string LoginTime time.Time LastSeen time.Time Data map[string]interface{} } type UserStore interface { InitiateSession(user string, password string) (string, error) ValidateUser(user string, sessionId string) (bool, error) EndSession(user string) error AddUser(user string, password string) error DeleteUser(user string) error ChangePassword(user string, oldPassword string, newPassword string) error } func Login(user string, password string, userStore UserStore) (string, error) { //ValidateUser (check user exists, hash and compare password) //InitiateUserSession (generate token and assign it to the user) //set username in cookie //return token, nil return "", nil } |