Documentation ¶
Index ¶
- func ConnectToDB(locOfDB string, dbName string) *mongo.Database
- type BasicUser
- func (basic *BasicUser) Activated() bool
- func (basic *BasicUser) CopyFrom(from User)
- func (basic *BasicUser) Email() string
- func (basic *BasicUser) Id() int
- func (basic *BasicUser) Password() string
- func (basic *BasicUser) PasswordLogin() bool
- func (basic *BasicUser) SetEmail(email string)
- func (basic *BasicUser) SetId(id int)
- func (basic *BasicUser) SetPassword(pw string)
- func (basic *BasicUser) SetToken(tk string)
- func (basic *BasicUser) Token() string
- type FacebookHandler
- type FacebookLoginToken
- type GoogleHandler
- type GoogleLoginToken
- type Handler
- type Helper
- type Repo
- type RepoMemory
- func (repo *RepoMemory) ActivateUser(user User) error
- func (repo *RepoMemory) AddUser(t User) (User, error)
- func (repo *RepoMemory) CleanUp()
- func (repo *RepoMemory) GetUser(id int) (User, error)
- func (repo *RepoMemory) GetUserByEmail(email string) (User, error)
- func (repo *RepoMemory) ListAllActiveUsers() ([]int, error)
- func (repo *RepoMemory) ListAllUsers() ([]int, error)
- func (repo *RepoMemory) NewEmptyUser() User
- func (repo *RepoMemory) UpdateUser(user User) (User, error)
- type RepoMongo
- type RepoSql
- func (repo *RepoSql) ActivateUser(user User) error
- func (repo *RepoSql) AddUser(newUser User) (User, error)
- func (repo *RepoSql) CleanUp()
- func (repo *RepoSql) GetUser(id int) (User, error)
- func (repo *RepoSql) GetUserByEmail(email string) (User, error)
- func (repo *RepoSql) ListAllActiveUsers() ([]int, error)
- func (repo *RepoSql) ListAllUsers() ([]int, error)
- func (repo *RepoSql) NewEmptyUser() User
- func (repo *RepoSql) UpdateUser(user User) (User, error)
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BasicUser ¶
type BasicUser struct { Id_ int `json:"id"` Email_ string `json:"email"` Token_ string `json:"token";sql:"-"` // contains filtered or unexported fields }
a struct to rep user account
func GetUserFromCursor ¶
func (*BasicUser) CopyFrom ¶
* Provide code to copy the user into this user
* Add the required setters and getters
func (*BasicUser) PasswordLogin ¶
func (*BasicUser) SetPassword ¶
type FacebookHandler ¶
type FacebookHandler struct {
// contains filtered or unexported fields
}
*
- This struct is used
func NewFacebookHandler ¶
func NewFacebookHandler(helper *Helper, configFiles ...string) *FacebookHandler
*
- This struct is used
func (*FacebookHandler) GetRoutes ¶
func (fbHandler *FacebookHandler) GetRoutes() []routing.Route
* Function used to get routes
type FacebookLoginToken ¶
type FacebookLoginToken struct { // The user handler needs to have access to user repo AccessToken string `json:"accessToken"` }
*
- This struct is used to get data from the post command
type GoogleHandler ¶
type GoogleHandler struct {
// contains filtered or unexported fields
}
*
- This struct is used
func NewGoogleHandler ¶
func NewGoogleHandler(helper *Helper, configFiles ...string) *GoogleHandler
*
- This struct is used
func (*GoogleHandler) GetRoutes ¶
func (gHandler *GoogleHandler) GetRoutes() []routing.Route
* Function used to get routes
type GoogleLoginToken ¶
type GoogleLoginToken struct { // The user handler needs to have access to user repo IdToken string `json:"id_token"` }
*
- This struct is used to get data from the post command
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
*
- This struct is used
type Helper ¶
type Repo ¶
type Repo interface { /** Get the user with the email. An error is thrown is not found */ GetUserByEmail(email string) (User, error) /** Get the user with the ID. An error is thrown is not found */ GetUser(id int) (User, error) /** Add User */ AddUser(user User) (User, error) /** Update User */ UpdateUser(user User) (User, error) /** Activate User */ ActivateUser(user User) error /** Allow databases to be closed */ CleanUp() /** Create empty user */ NewEmptyUser() User /** List all users */ ListAllUsers() ([]int, error) ListAllActiveUsers() ([]int, error) }
* Define an interface that all Calc Repos must follow
type RepoMemory ¶
type RepoMemory struct {
// contains filtered or unexported fields
}
* Define a struct for Repo for use with users
func (*RepoMemory) ActivateUser ¶
func (repo *RepoMemory) ActivateUser(user User) error
* List all users
func (*RepoMemory) AddUser ¶
func (repo *RepoMemory) AddUser(t User) (User, error)
* Add the user to the database
func (*RepoMemory) CleanUp ¶
func (repo *RepoMemory) CleanUp()
* Clean up the database, nothing much to do
func (*RepoMemory) GetUser ¶
func (repo *RepoMemory) GetUser(id int) (User, error)
* Look up the user by id and return if they were found
func (*RepoMemory) GetUserByEmail ¶
func (repo *RepoMemory) GetUserByEmail(email string) (User, error)
* Look up the user and return if they were found
func (*RepoMemory) ListAllActiveUsers ¶
func (repo *RepoMemory) ListAllActiveUsers() ([]int, error)
func (*RepoMemory) ListAllUsers ¶
func (repo *RepoMemory) ListAllUsers() ([]int, error)
* List all users
func (*RepoMemory) NewEmptyUser ¶
func (repo *RepoMemory) NewEmptyUser() User
* Clean up the database, nothing much to do
func (*RepoMemory) UpdateUser ¶
func (repo *RepoMemory) UpdateUser(user User) (User, error)
* Update the user table. No checks are made here,
type RepoMongo ¶
type RepoMongo struct {
// contains filtered or unexported fields
}
* Define a struct for Repo for use with users
func NewRepoMongo ¶
Provide a metho to make a new Mongo Repo
func (*RepoMongo) GetUserByEmail ¶
Provide a method to make a new UserRepoSql * Get the user with the email. An error is thrown is not found
type RepoSql ¶
type RepoSql struct {
// contains filtered or unexported fields
}
* Define a struct for Repo for use with users
func NewRepoMySql ¶
Provide a method to make a new UserRepoSql
func NewRepoPostgresSql ¶
Provide a method to make a new UserRepoSql
func (*RepoSql) ActivateUser ¶
* Update the user table. No checks are made here,
func (*RepoSql) CleanUp ¶
func (repo *RepoSql) CleanUp()
* Clean up the database, nothing much to do
func (*RepoSql) GetUserByEmail ¶
* Look up the user and return if they were found
func (*RepoSql) ListAllActiveUsers ¶
* List all of the users
func (*RepoSql) ListAllUsers ¶
* List all of the users
func (*RepoSql) NewEmptyUser ¶
* Clean up the database, nothing much to do
type User ¶
type User interface { //Return the user id Id() int SetId(id int) //Return the user email Email() string SetEmail(email string) //Get the password Password() string SetPassword(password string) //Return the user email Token() string SetToken(token string) //Check if the user was activated Activated() bool //Check to see if the user can login with a password PasswordLogin() bool }
a struct to rep user account