Versions in this module Expand all Collapse all v0 v0.0.0 Aug 29, 2016 Changes in this version + const AuthenticatedAccountKey + const AuthenticatedUserKey + var ErrAccountAuthenticationRequired = errors.New("Account authentication required") + var ErrAccountNameTaken = errors.New("Account name taken") + var ErrAccountNotFound = errors.New("Account not found") + var ErrConfirmationNotFound = errors.New("Confirmation not found") + var ErrGetUserPermission = errors.New("Need permission to get user") + var ErrInvitationNotFound = errors.New("Invitation not found") + var ErrPasswordResetNotFound = errors.New("Password reset not found") + var ErrRoleNotFound = errors.New("Role not found") + var ErrSuperuserOnlyManually = errors.New("Superusers can only be created manually") + var ErrUpdateUserPermission = errors.New("Need permission to update user") + var ErrUserAuthenticationRequired = errors.New("User authentication required") + var ErrUserNotFound = errors.New("User not found") + func AccountPreload(db *gorm.DB) *gorm.DB + func AccountPreloadWithPrefix(db *gorm.DB, prefix string) *gorm.DB + func ConfirmationPreload(db *gorm.DB) *gorm.DB + func ConfirmationPreloadWithPrefix(db *gorm.DB, prefix string) *gorm.DB + func InvitationPreload(db *gorm.DB) *gorm.DB + func InvitationPreloadWithPrefix(db *gorm.DB, prefix string) *gorm.DB + func MigrateAll(db *gorm.DB) error + func PasswordResetPreload(db *gorm.DB) *gorm.DB + func PasswordResetPreloadWithPrefix(db *gorm.DB, prefix string) *gorm.DB + func RegisterRoutes(router *mux.Router, service ServiceInterface) + func UserPreload(db *gorm.DB) *gorm.DB + func UserPreloadWithPrefix(db *gorm.DB, prefix string) *gorm.DB + type Account struct + Description sql.NullString + Name string + OauthClient *oauth.Client + OauthClientID sql.NullInt64 + func GetAuthenticatedAccount(r *http.Request) (*Account, error) + func NewAccount(oauthClient *oauth.Client, name, description string) *Account + func (p *Account) TableName() string + type AccountAuthMiddleware struct + func NewAccountAuthMiddleware(service ServiceInterface) *AccountAuthMiddleware + func (m *AccountAuthMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) + type ConfirmInvitationRequest struct + type ConfirmPasswordResetRequest struct + type Confirmation struct + EmailSent bool + EmailSentAt pq.NullTime + Reference string + User *User + UserID sql.NullInt64 + func NewConfirmation(user *User) *Confirmation + func (c *Confirmation) TableName() string + type EmailFactory struct + func NewEmailFactory(cnf *config.Config) *EmailFactory + func (f *EmailFactory) NewConfirmationEmail(confirmation *Confirmation) (*email.Message, error) + func (f *EmailFactory) NewInvitationEmail(invitation *Invitation) (*email.Message, error) + func (f *EmailFactory) NewPasswordResetEmail(passwordReset *PasswordReset) (*email.Message, error) + type EmailFactoryInterface interface + NewConfirmationEmail func(confirmation *Confirmation) (*email.Message, error) + NewInvitationEmail func(invitation *Invitation) (*email.Message, error) + NewPasswordResetEmail func(passwordReset *PasswordReset) (*email.Message, error) + type Invitation struct + EmailSent bool + EmailSentAt pq.NullTime + InvitedByUser *User + InvitedByUserID sql.NullInt64 + InvitedUser *User + InvitedUserID sql.NullInt64 + Reference string + func NewInvitation(invitedUser, invitedByUser *User) *Invitation + func (i *Invitation) TableName() string + type InvitationRequest struct + Email string + FirstName string + LastName string + type OptionalUserAuthMiddleware struct + func NewOptionalUserAuthMiddleware(service ServiceInterface) *OptionalUserAuthMiddleware + func (m *OptionalUserAuthMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) + type PasswordRequest struct + Password string + type PasswordReset struct + EmailSent bool + EmailSentAt pq.NullTime + Reference string + User *User + UserID sql.NullInt64 + func NewPasswordReset(user *User) *PasswordReset + func (p *PasswordReset) TableName() string + type PasswordResetRequest struct + Email string + type Role struct + ID string + Name string + func (r *Role) TableName() string + type Service struct + func NewService(cnf *config.Config, db *gorm.DB, oauthService oauth.ServiceInterface, ...) *Service + func (s *Service) ConfirmEmailHandler(w http.ResponseWriter, r *http.Request) + func (s *Service) ConfirmInvitation(invitation *Invitation, password string) error + func (s *Service) ConfirmInvitationHandler(w http.ResponseWriter, r *http.Request) + func (s *Service) ConfirmPasswordResetHandler(w http.ResponseWriter, r *http.Request) + func (s *Service) ConfirmUser(user *User) error + func (s *Service) CreateAccount(name, description, key, secret, redirectURI string) (*Account, error) + func (s *Service) CreatePasswordResetHandler(w http.ResponseWriter, r *http.Request) + func (s *Service) CreateSuperuser(account *Account, email, password string) (*User, error) + func (s *Service) CreateUser(account *Account, userRequest *UserRequest) (*User, error) + func (s *Service) CreateUserHandler(w http.ResponseWriter, r *http.Request) + func (s *Service) CreateUserTx(tx *gorm.DB, account *Account, userRequest *UserRequest) (*User, error) + func (s *Service) FindAccountByID(accountID uint) (*Account, error) + func (s *Service) FindAccountByName(name string) (*Account, error) + func (s *Service) FindAccountByOauthClientID(oauthClientID uint) (*Account, error) + func (s *Service) FindConfirmationByReference(reference string) (*Confirmation, error) + func (s *Service) FindInvitationByID(id uint) (*Invitation, error) + func (s *Service) FindInvitationByReference(reference string) (*Invitation, error) + func (s *Service) FindPasswordResetByReference(reference string) (*PasswordReset, error) + func (s *Service) FindRoleByID(id string) (*Role, error) + func (s *Service) FindUserByEmail(email string) (*User, error) + func (s *Service) FindUserByFacebookID(facebookID string) (*User, error) + func (s *Service) FindUserByID(userID uint) (*User, error) + func (s *Service) FindUserByOauthUserID(oauthUserID uint) (*User, error) + func (s *Service) GetClientCredentials(r *http.Request) (*Account, *User, error) + func (s *Service) GetConfig() *config.Config + func (s *Service) GetMyUserHandler(w http.ResponseWriter, r *http.Request) + func (s *Service) GetOauthService() oauth.ServiceInterface + func (s *Service) GetOrCreateFacebookUser(account *Account, facebookID string, userRequest *UserRequest) (*User, error) + func (s *Service) GetUserCredentials(token string) (*Account, *User, error) + func (s *Service) GetUserHandler(w http.ResponseWriter, r *http.Request) + func (s *Service) InviteUser(invitedByUser *User, invitationRequest *InvitationRequest) (*Invitation, error) + func (s *Service) InviteUserHandler(w http.ResponseWriter, r *http.Request) + func (s *Service) InviteUserTx(tx *gorm.DB, invitedByUser *User, invitationRequest *InvitationRequest) (*Invitation, error) + func (s *Service) ResetPassword(passwordReset *PasswordReset, password string) error + func (s *Service) UpdateUser(user *User, userRequest *UserRequest) error + func (s *Service) UpdateUserHandler(w http.ResponseWriter, r *http.Request) + type ServiceInterface interface + ConfirmEmailHandler func(w http.ResponseWriter, r *http.Request) + ConfirmInvitation func(invitation *Invitation, password string) error + ConfirmInvitationHandler func(w http.ResponseWriter, r *http.Request) + ConfirmPasswordResetHandler func(w http.ResponseWriter, r *http.Request) + ConfirmUser func(user *User) error + CreateAccount func(name, description, key, secret, redirectURI string) (*Account, error) + CreatePasswordResetHandler func(w http.ResponseWriter, r *http.Request) + CreateSuperuser func(account *Account, email, password string) (*User, error) + CreateUser func(account *Account, userRequest *UserRequest) (*User, error) + CreateUserHandler func(w http.ResponseWriter, r *http.Request) + CreateUserTx func(tx *gorm.DB, account *Account, userRequest *UserRequest) (*User, error) + FindAccountByID func(accountID uint) (*Account, error) + FindAccountByName func(name string) (*Account, error) + FindAccountByOauthClientID func(oauthClientID uint) (*Account, error) + FindConfirmationByReference func(reference string) (*Confirmation, error) + FindInvitationByID func(invitationID uint) (*Invitation, error) + FindInvitationByReference func(reference string) (*Invitation, error) + FindPasswordResetByReference func(reference string) (*PasswordReset, error) + FindUserByEmail func(email string) (*User, error) + FindUserByFacebookID func(facebookID string) (*User, error) + FindUserByID func(userID uint) (*User, error) + FindUserByOauthUserID func(oauthUserID uint) (*User, error) + GetClientCredentials func(r *http.Request) (*Account, *User, error) + GetConfig func() *config.Config + GetMyUserHandler func(w http.ResponseWriter, r *http.Request) + GetOauthService func() oauth.ServiceInterface + GetOrCreateFacebookUser func(account *Account, facebookID string, userRequest *UserRequest) (*User, error) + GetUserCredentials func(token string) (*Account, *User, error) + GetUserHandler func(w http.ResponseWriter, r *http.Request) + InviteUser func(invitedByUser *User, invitationRequest *InvitationRequest) (*Invitation, error) + InviteUserHandler func(w http.ResponseWriter, r *http.Request) + InviteUserTx func(tx *gorm.DB, invitedByUser *User, invitationRequest *InvitationRequest) (*Invitation, error) + ResetPassword func(passwordReset *PasswordReset, password string) error + UpdateUser func(user *User, userRequest *UserRequest) error + UpdateUserHandler func(w http.ResponseWriter, r *http.Request) + type User struct + Account *Account + AccountID sql.NullInt64 + Confirmed bool + FacebookID sql.NullString + FirstName sql.NullString + LastName sql.NullString + OauthUser *oauth.User + OauthUserID sql.NullInt64 + Picture sql.NullString + Role *Role + RoleID sql.NullString + func GetAuthenticatedUser(r *http.Request) (*User, error) + func NewUser(account *Account, oauthUser *oauth.User, role *Role, facebookID string, ...) *User + func (u *User) GetName() string + func (u *User) TableName() string + type UserAuthMiddleware struct + func NewUserAuthMiddleware(service ServiceInterface) *UserAuthMiddleware + func (m *UserAuthMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) + type UserRequest struct + Email string + FirstName string + LastName string + NewPassword string + Password string + Picture string + Role string + type UserResponse struct + Confirmed bool + CreatedAt string + Email string + FirstName string + ID uint + LastName string + Picture string + Role string + UpdatedAt string + func NewUserResponse(user *User) (*UserResponse, error)