passwords

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: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicHelper

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

func NewBasicHelper

func NewBasicHelper(configFiles ...string) *BasicHelper

Load it during init

func (*BasicHelper) ComparePasswords

func (helper *BasicHelper) ComparePasswords(currentPwHash string, testingPassword string) bool

*

Compare passwords.  Determine if they match

func (*BasicHelper) CreateJWTToken

func (helper *BasicHelper) CreateJWTToken(userId int, email string) string

*

Support function to generate a JWT token

func (*BasicHelper) HashPassword

func (helper *BasicHelper) HashPassword(password string) string

* Support function to hash the password

func (*BasicHelper) TokenGenerator

func (helper *BasicHelper) TokenGenerator() string

*

  • Get a random token

func (*BasicHelper) ValidatePassword

func (helper *BasicHelper) ValidatePassword(password string) error

* Make sure that the password is valid

func (*BasicHelper) ValidateToken

func (helper *BasicHelper) ValidateToken(tokenHeader string) (int, string, error)

*

Compare passwords.  Determine if they match

type Helper

type Helper interface {
	HashPassword(password string) string
	CreateJWTToken(userId int, email string) string
	ComparePasswords(currentPwHash string, testingPassword string) bool
	TokenGenerator() string
	ValidateToken(tokenHeader string) (int, string, error)
	ValidatePassword(password string) error
}

type PasswordResetConfig

type PasswordResetConfig struct {
	Template string `json:"template"`
	Subject  string `json:"subject"`
}

Define a struct to store password reset configs

type PasswordResetInfo

type PasswordResetInfo struct {
	Token string `json:"token"`
	Email string `json:"email"`
}

Define a struct to store password reset configs

type ResetRepo

type ResetRepo interface {

	/**
	Issues a request for the user
	*/
	IssueResetRequest(token string, userId int, email string) error

	/**
	Issues a request for the user
	*/
	CheckForResetToken(userId int, reset_token string) (int, error)

	/**
	Issues a request for the user
	*/
	IssueActivationRequest(token string, userId int, email string) error

	/**
	Issues a request for the user
	*/
	CheckForActivationToken(userId int, activationToken string) (int, error)

	/**
	Issues a request for the user
	*/
	UseToken(id int) error

	/**
	Allow databases to be closed
	*/
	CleanUp()
}

* Define an interface that all Calc Repos must follow

type ResetRepoSql

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

* Define a struct for Repo for use with users

func NewRepoMySql

func NewRepoMySql(db *sql.DB, tableName string, emailer email.Interface, configFile string) *ResetRepoSql

Provide a method to make a new UserRepoSql

func NewRepoPostgresSql

func NewRepoPostgresSql(db *sql.DB, tableName string, emailer email.Interface, configFile ...string) *ResetRepoSql

Provide a method to make a new UserRepoSql

func (*ResetRepoSql) CheckForActivationToken

func (repo *ResetRepoSql) CheckForActivationToken(userId int, token string) (int, error)

* Use the taken to validate

func (*ResetRepoSql) CheckForResetToken

func (repo *ResetRepoSql) CheckForResetToken(userId int, token string) (int, error)

* Use the taken to validate

func (*ResetRepoSql) CleanUp

func (repo *ResetRepoSql) CleanUp()

* Clean up the database, nothing much to do

func (*ResetRepoSql) IssueActivationRequest

func (repo *ResetRepoSql) IssueActivationRequest(token string, userId int, emailAddress string) error

* Look up the user and return if they were found

func (*ResetRepoSql) IssueResetRequest

func (repo *ResetRepoSql) IssueResetRequest(token string, userId int, emailAddress string) error

* Look up the user and return if they were found

func (*ResetRepoSql) UseToken

func (repo *ResetRepoSql) UseToken(id int) error

type Token

type Token struct {
	UserId int
	Email  string
	jwt.StandardClaims
}

JWT claims struct

Jump to

Keyboard shortcuts

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