user

package
v0.0.0-...-5a77029 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const PostgresqlErrorCodeNoData = "02000"

PostgresqlErrorCodeNoData = no_data warning

View Source
const PostgresqlErrorCodeUniqueViolation = "23505"

PostgresqlErrorCodeUniqueViolation is a unique_violation, https://postgrespro.ru/docs/postgrespro/9.5/errcodes-appendix

Variables

This section is empty.

Functions

func ChangePasswordFormPageHandler

func ChangePasswordFormPageHandler(c *gin.Context)

ChangePasswordFormPageHandler renders a /changepasswordform page

func ChangePasswordSubmitPageHandler

func ChangePasswordSubmitPageHandler(c *gin.Context)

ChangePasswordSubmitPageHandler processes a /changepasswordsubmit form post request

func CheckPasswordAgainstSaltAndHash

func CheckPasswordAgainstSaltAndHash(password, saltBase64, dkBase64 string) bool

CheckPasswordAgainstSaltAndHash matches password to hash/salt pair

func EnsureLoggedIn

func EnsureLoggedIn(c *gin.Context)

EnsureLoggedIn causes a request to be aborted with an error if the user is not logged in. Can only be used downstream from SetUserStatusMiddleware middleware

func EnsureNotLoggedIn

func EnsureNotLoggedIn(c *gin.Context)

EnsureNotLoggedIn ensures that a request will be aborted with an error if the user is already logged in. Can only be used downstream from SetUserStatusMiddleware middleware

func GenNonce

func GenNonce(length uint8) string

GenNonce Generates a random string of bytes, base64 encoded Inspired by the discussion in the https://github.com/joestump/python-oauth2/issues/9#

func GetSDUserIdOrZero

func GetSDUserIdOrZero(c *gin.Context) int32

GetSDUserIdOrZero returns sduserid for a logged in user, or 0 for a not logged Use downstream from SetUserStatusMiddleware middleware

func IsLoggedIn

func IsLoggedIn(c *gin.Context) bool

IsLoggedIn is true if the user is logged in with valid credentials. Can only be used downstream from SetUserStatusMiddleware middleware

func LoginFormPageHandler

func LoginFormPageHandler(c *gin.Context)

LoginFormPageHandler renders a /loginform page

func LoginSubmitPostHandler

func LoginSubmitPostHandler(c *gin.Context)

LoginSubmitPostHandler handles login route

func Logout

func Logout(c *gin.Context)

Logout performs a logout

func RegistrationConfirmationPageHandler

func RegistrationConfirmationPageHandler(c *gin.Context)

RegistrationConfirmationPageHandler processes a registration confirmation

func RegistrationFormPageHandler

func RegistrationFormPageHandler(c *gin.Context)

RegistrationFormPageHandler renders a /registrationform page

func RegistrationSubmitPostHandler

func RegistrationSubmitPostHandler(c *gin.Context)

RegistrationSubmitPostHandler processes a registrationsubmit form post request

func RestorePasswordFormPageHandler

func RestorePasswordFormPageHandler(c *gin.Context)

RestorePasswordFormPageHandler renders a /restorepasswordform page

func RestorePasswordSubmitPageHandler

func RestorePasswordSubmitPageHandler(c *gin.Context)

RestorePasswordSubmitPageHandler processes a /restorepasswordsubmit form post request

func SaltAndHashPassword

func SaltAndHashPassword(password string) (saltBase64, dkBase64 string)

SaltAndHashPassword generates a dynamic salt, hash and return both https://habr.com/ru/post/145648/

func SendEmail

func SendEmail(recieverEMail, subj, html string) (err error)

SendEmail sends an email, or, if fakeEmail() is true, prints it to stdout Sender, SMTP server and credentials are taken from semdict.config.json (loaded when program starts)

func SetUserStatusMiddleware

func SetUserStatusMiddleware() gin.HandlerFunc

SetUserStatusMiddleware sets a flag indicating whether the request was from an authenticated user or not

Types

type RegistrationData

type RegistrationData struct {
	Nickname          string
	Registrationemail string
	Password1         string
	Password2         string
	Salt              string
	Hash              string
	ConfirmationKey   string
	UserID            int32
}

RegistrationData is a transient struct containing data obtained from a /registrationsubmit query as well as some of calculated data

type SDUserData

type SDUserData struct {
	ID                    int32
	Nickname              string
	Registrationemail     string
	Salt                  string
	Hash                  string
	RegistrationTimestamp time.Time
}

SDUserData is based on sduser table

Jump to

Keyboard shortcuts

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