auth

Paddy 2014-09-01 Child:1f7b44b130a0

27:043906283c65 Go to Latest

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.

History
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/profile.go	Mon Sep 01 09:19:06 2014 -0400
     1.3 @@ -0,0 +1,36 @@
     1.4 +package auth
     1.5 +
     1.6 +import (
     1.7 +	"time"
     1.8 +
     1.9 +	"secondbit.org/uuid"
    1.10 +)
    1.11 +
    1.12 +type Profile struct {
    1.13 +	ID         uuid.ID
    1.14 +	Name       string
    1.15 +	Passphrase string
    1.16 +	Email      string
    1.17 +	Created    time.Time
    1.18 +	LastSeen   time.Time
    1.19 +}
    1.20 +
    1.21 +type Login struct {
    1.22 +	Type      string
    1.23 +	Value     string
    1.24 +	ProfileID uuid.ID
    1.25 +	Created   time.Time
    1.26 +	LastUsed  time.Time
    1.27 +}
    1.28 +
    1.29 +type ProfileStore interface {
    1.30 +	GetProfileByID(id uuid.ID) (Profile, error)
    1.31 +	GetProfileByLogin(loginType, value, passphrase string) (Profile, error)
    1.32 +	SaveProfile(user Profile) error
    1.33 +	UpdateProfile(id uuid.ID, name, passphrase, email *string) error
    1.34 +	DeleteProfile(id uuid.ID) error
    1.35 +
    1.36 +	SaveLogin(login Login) error
    1.37 +	DeleteLogin(login Login) error
    1.38 +	UpdateLogin(id uuid.ID, lastUsed time.Time) error
    1.39 +}