auth
2014-09-01
Child:1f7b44b130a0
auth/profile.go
Rough out profiles. Create a Profile type that stores information about user profiles. Create a Login type that stores information about a login strategy for user profiles. This is necessary so that a user can login with their username or email address, with usernames not being required if an email address is supplied and email addresses not being required if a username is supplied.
| paddy@27 | 1 package auth |
| paddy@27 | 2 |
| paddy@27 | 3 import ( |
| paddy@27 | 4 "time" |
| paddy@27 | 5 |
| paddy@27 | 6 "secondbit.org/uuid" |
| paddy@27 | 7 ) |
| paddy@27 | 8 |
| paddy@27 | 9 type Profile struct { |
| paddy@27 | 10 ID uuid.ID |
| paddy@27 | 11 Name string |
| paddy@27 | 12 Passphrase string |
| paddy@27 | 13 Email string |
| paddy@27 | 14 Created time.Time |
| paddy@27 | 15 LastSeen time.Time |
| paddy@27 | 16 } |
| paddy@27 | 17 |
| paddy@27 | 18 type Login struct { |
| paddy@27 | 19 Type string |
| paddy@27 | 20 Value string |
| paddy@27 | 21 ProfileID uuid.ID |
| paddy@27 | 22 Created time.Time |
| paddy@27 | 23 LastUsed time.Time |
| paddy@27 | 24 } |
| paddy@27 | 25 |
| paddy@27 | 26 type ProfileStore interface { |
| paddy@27 | 27 GetProfileByID(id uuid.ID) (Profile, error) |
| paddy@27 | 28 GetProfileByLogin(loginType, value, passphrase string) (Profile, error) |
| paddy@27 | 29 SaveProfile(user Profile) error |
| paddy@27 | 30 UpdateProfile(id uuid.ID, name, passphrase, email *string) error |
| paddy@27 | 31 DeleteProfile(id uuid.ID) error |
| paddy@27 | 32 |
| paddy@27 | 33 SaveLogin(login Login) error |
| paddy@27 | 34 DeleteLogin(login Login) error |
| paddy@27 | 35 UpdateLogin(id uuid.ID, lastUsed time.Time) error |
| paddy@27 | 36 } |