users

package
v0.0.0-...-a894b33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectToDB

func ConnectToDB(locOfDB string, dbName string) *mongo.Database

Connect to a db, returns pointer to db

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 GetUserFromCursor(cursor mongo.Cursor) *BasicUser

func (*BasicUser) Activated

func (basic *BasicUser) Activated() bool

func (*BasicUser) CopyFrom

func (basic *BasicUser) CopyFrom(from User)

* Provide code to copy the user into this user

* Add the required setters and getters

func (*BasicUser) Email

func (basic *BasicUser) Email() string

func (*BasicUser) Id

func (basic *BasicUser) Id() int

* Add the required setters and getters

func (*BasicUser) Password

func (basic *BasicUser) Password() string
func (basic *BasicUser) SetId(id int)  {
	basic.Id_ = id
}

func (*BasicUser) PasswordLogin

func (basic *BasicUser) PasswordLogin() bool

func (*BasicUser) SetEmail

func (basic *BasicUser) SetEmail(email string)

func (*BasicUser) SetId

func (basic *BasicUser) SetId(id int)

func (*BasicUser) SetPassword

func (basic *BasicUser) SetPassword(pw string)

func (*BasicUser) SetToken

func (basic *BasicUser) SetToken(tk string)

func (*BasicUser) Token

func (basic *BasicUser) Token() string

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

func NewHandler

func NewHandler(userHelper *Helper, allowUserCreation bool) *Handler

*

  • This struct is used

func (*Handler) GetRoutes

func (handler *Handler) GetRoutes() []routing.Route

* Function used to get routes

type Helper

type Helper struct {

	//Hold the user repo
	Repo

	//And the password repo
	passwords.ResetRepo
	// contains filtered or unexported fields
}

func NewUserHelper

func NewUserHelper(usersRepo Repo, passRepo passwords.ResetRepo, passwordHelper passwords.Helper) *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 NewRepoMemory

func NewRepoMemory() *RepoMemory

Provide a method to make a new UserRepoMemory

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

func NewRepoMongo(locOfDB string, dbName string, collection string) *RepoMongo

Provide a metho to make a new Mongo Repo

func (*RepoMongo) GetUserByEmail

func (repo *RepoMongo) GetUserByEmail(email string) (User, error)

Provide a method to make a new UserRepoSql * Get the user with the email. An error is thrown is not found

func (*RepoMongo) QueryBD

func (repo *RepoMongo) QueryBD(queryString bson.D) *mongo.Cursor

query DB, returns cursor

type RepoSql

type RepoSql struct {
	// contains filtered or unexported fields
}

* Define a struct for Repo for use with users

func NewRepoMySql

func NewRepoMySql(db *sql.DB, tableName string) *RepoSql

Provide a method to make a new UserRepoSql

func NewRepoPostgresSql

func NewRepoPostgresSql(db *sql.DB, tableName string) *RepoSql

Provide a method to make a new UserRepoSql

func (*RepoSql) ActivateUser

func (repo *RepoSql) ActivateUser(user User) error

* Update the user table. No checks are made here,

func (*RepoSql) AddUser

func (repo *RepoSql) AddUser(newUser User) (User, error)

* Add the user to the database

func (*RepoSql) CleanUp

func (repo *RepoSql) CleanUp()

* Clean up the database, nothing much to do

func (*RepoSql) GetUser

func (repo *RepoSql) GetUser(id int) (User, error)

* Look up the user by id and return if they were found

func (*RepoSql) GetUserByEmail

func (repo *RepoSql) GetUserByEmail(email string) (User, error)

* Look up the user and return if they were found

func (*RepoSql) ListAllActiveUsers

func (repo *RepoSql) ListAllActiveUsers() ([]int, error)

* List all of the users

func (*RepoSql) ListAllUsers

func (repo *RepoSql) ListAllUsers() ([]int, error)

* List all of the users

func (*RepoSql) NewEmptyUser

func (repo *RepoSql) NewEmptyUser() User

* Clean up the database, nothing much to do

func (*RepoSql) UpdateUser

func (repo *RepoSql) UpdateUser(user User) (User, error)

* Update the user table. No checks are made here,

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL