Documentation ¶
Index ¶
- Constants
- func ChangePasswordFormPageHandler(c *gin.Context)
- func ChangePasswordSubmitPageHandler(c *gin.Context)
- func CheckPasswordAgainstSaltAndHash(password, saltBase64, dkBase64 string) bool
- func EnsureLoggedIn(c *gin.Context)
- func EnsureNotLoggedIn(c *gin.Context)
- func GenNonce(length uint8) string
- func GetSDUserIdOrZero(c *gin.Context) int32
- func IsLoggedIn(c *gin.Context) bool
- func LoginFormPageHandler(c *gin.Context)
- func LoginSubmitPostHandler(c *gin.Context)
- func Logout(c *gin.Context)
- func RegistrationConfirmationPageHandler(c *gin.Context)
- func RegistrationFormPageHandler(c *gin.Context)
- func RegistrationSubmitPostHandler(c *gin.Context)
- func RestorePasswordFormPageHandler(c *gin.Context)
- func RestorePasswordSubmitPageHandler(c *gin.Context)
- func SaltAndHashPassword(password string) (saltBase64, dkBase64 string)
- func SendEmail(recieverEMail, subj, html string) (err error)
- func SetUserStatusMiddleware() gin.HandlerFunc
- type RegistrationData
- type SDUserData
Constants ¶
const PostgresqlErrorCodeNoData = "02000"
PostgresqlErrorCodeNoData = no_data warning
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 ¶
ChangePasswordFormPageHandler renders a /changepasswordform page
func ChangePasswordSubmitPageHandler ¶
ChangePasswordSubmitPageHandler processes a /changepasswordsubmit form post request
func CheckPasswordAgainstSaltAndHash ¶
CheckPasswordAgainstSaltAndHash matches password to hash/salt pair
func EnsureLoggedIn ¶
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 ¶
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 ¶
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 ¶
GetSDUserIdOrZero returns sduserid for a logged in user, or 0 for a not logged Use downstream from SetUserStatusMiddleware middleware
func IsLoggedIn ¶
IsLoggedIn is true if the user is logged in with valid credentials. Can only be used downstream from SetUserStatusMiddleware middleware
func LoginFormPageHandler ¶
LoginFormPageHandler renders a /loginform page
func LoginSubmitPostHandler ¶
LoginSubmitPostHandler handles login route
func RegistrationConfirmationPageHandler ¶
RegistrationConfirmationPageHandler processes a registration confirmation
func RegistrationFormPageHandler ¶
RegistrationFormPageHandler renders a /registrationform page
func RegistrationSubmitPostHandler ¶
RegistrationSubmitPostHandler processes a registrationsubmit form post request
func RestorePasswordFormPageHandler ¶
RestorePasswordFormPageHandler renders a /restorepasswordform page
func RestorePasswordSubmitPageHandler ¶
RestorePasswordSubmitPageHandler processes a /restorepasswordsubmit form post request
func SaltAndHashPassword ¶
SaltAndHashPassword generates a dynamic salt, hash and return both https://habr.com/ru/post/145648/
func SendEmail ¶
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