Documentation ¶
Index ¶
- Constants
- func Activate(c *gin.Context, actionPaths *ActionPaths)
- func Login(c *gin.Context, actionPaths *ActionPaths)
- func LoginForm(c *gin.Context, actionPaths *ActionPaths)
- func Logout(c *gin.Context, actionPaths *ActionPaths)
- func Register(c *gin.Context, actionPaths *ActionPaths)
- func RegisterForm(c *gin.Context, actionPaths *ActionPaths)
- func RequestResetPassword(c *gin.Context, actionPaths *ActionPaths)
- func RequestResetPasswordForm(c *gin.Context, actionPaths *ActionPaths)
- func ResetPasswordForm(c *gin.Context, actionPaths *ActionPaths)
- func ResetPasswordWithToken(c *gin.Context, actionPaths *ActionPaths)
- func Routes(r gin.IRouter, actionPaths ActionPaths)
- func WAPIIsLoggedIn(c *gin.Context)
- func WAPILogin(c *gin.Context, actionPaths *ActionPaths)
- func WAPILogout(c *gin.Context)
- func WAPIRegister(c *gin.Context, actionPaths *ActionPaths)
- func WAPIRequestPasswordReset(c *gin.Context, actionPaths *ActionPaths)
- func WAPIResetPasswordWithToken(c *gin.Context, actionPaths *ActionPaths)
- func WAPIRoutes(r gin.IRouter, actionPaths ActionPaths)
- type ActionPaths
- type EmailUserAuthRenderData
- type FailRes
- type HandlerWithEmailRegistration
- type LoginPayload
- type OKRes
- type RegisterPayload
- type RequestResetPasswordPayload
- type ResetPasswordWithTokenPayload
Constants ¶
const ( PathRegister string = "register" PathActivate string = "activate" PathLogin string = "login" PathLogout string = "logout" PathRequestPasswordReset string = "requestresetpassword" PathResetPassword string = "resetpassword" TemplLogin string = "wusers_login.html" TemplRegisterForm string = "wusers_register.html" TemplActivationSent string = "wusers_registration_activation_sent.html" TemplActivateBadToken string = "wusers_registration_activation_bad_token.html" TemplActivateSuccess string = "wusers_registration_activation_success.html" TemplLoginForm string = "wusers_login.html" TemplLoginSuccess string = "wusers_login_completed.html" TemplLogoutSuccess string = "wusers_login_completed.html" TemplRequestResetPasswordForm string = "wusers_registration_request_password_reset_form.html" TemplResetPasswordTokenSent string = "wusers_registration_reset_password_token_sent.html" TemplResetPasswordForm string = "wusers_registration_reset_password_form.html" TemplResetPasswordSuccess string = "wusers_registration_reset_password_success.html" )
These are the definitions for paths and template names for user registration flows.
const ( // PathIsLoggedIn is the path to check if a user is logged in. PathIsLoggedIn string = "loggedin" )
Variables ¶
This section is empty.
Functions ¶
func Activate ¶
func Activate(c *gin.Context, actionPaths *ActionPaths)
Activate a registered user with the activation token
func Login ¶
func Login(c *gin.Context, actionPaths *ActionPaths)
Login executes the login got a given user
func LoginForm ¶
func LoginForm(c *gin.Context, actionPaths *ActionPaths)
LoginForm returns the template to render the login page
func Register ¶
func Register(c *gin.Context, actionPaths *ActionPaths)
Register implements the user registration api request
func RegisterForm ¶
func RegisterForm(c *gin.Context, actionPaths *ActionPaths)
RegisterForm returns the template for the registration form
func RequestResetPassword ¶
func RequestResetPassword(c *gin.Context, actionPaths *ActionPaths)
RequestResetPassword send an email to reset a password
func RequestResetPasswordForm ¶
func RequestResetPasswordForm(c *gin.Context, actionPaths *ActionPaths)
RequestResetPasswordForm renders a form to reset a password with a given token
func ResetPasswordForm ¶
func ResetPasswordForm(c *gin.Context, actionPaths *ActionPaths)
ResetPasswordForm renders a form to reset a password with a given token
func ResetPasswordWithToken ¶
func ResetPasswordWithToken(c *gin.Context, actionPaths *ActionPaths)
ResetPasswordWithToken sets a new password for a user with the password reset token sent
func Routes ¶
func Routes(r gin.IRouter, actionPaths ActionPaths)
Routes setup the routes for the user registration, login and reset password flows.
func WAPIIsLoggedIn ¶
WAPIIsLoggedIn is the handler to check if a user is logged in.
func WAPILogin ¶
func WAPILogin(c *gin.Context, actionPaths *ActionPaths)
WAPILogin is the handler for the login user endpoint.
func WAPIRegister ¶
func WAPIRegister(c *gin.Context, actionPaths *ActionPaths)
WAPIRegister is the handler for the register user endpoint.
func WAPIRequestPasswordReset ¶
func WAPIRequestPasswordReset(c *gin.Context, actionPaths *ActionPaths)
WAPIRequestPasswordReset is the handler for the request password reset endpoint.
func WAPIResetPasswordWithToken ¶
func WAPIResetPasswordWithToken(c *gin.Context, actionPaths *ActionPaths)
WAPIResetPasswordWithToken is the handler to change a password with a reset password token.
func WAPIRoutes ¶
func WAPIRoutes(r gin.IRouter, actionPaths ActionPaths)
WAPIRoutes create the routes for the endpoints to be used from the web app.
Types ¶
type ActionPaths ¶
ActionPaths indicates the path to where to redierect from registration emails
- BasePath: fallback, if other paths are not explictily set
- ActivationPath: the path to were to redirect when activating a user (the token param will be appended to it)
- ResetPasswordPath: the path to were to redirect a user with' a reset password token (the token param will be appended to it)
type EmailUserAuthRenderData ¶
type EmailUserAuthRenderData struct { LoginURL string RegisterURL string RequestPasswordResetURL string FormErrors []string }
EmailUserAuthRenderData contains the data required to render templates tha point to the actual running server.
func NewEmailUserAuthRenderData ¶
func NewEmailUserAuthRenderData(basePath string) *EmailUserAuthRenderData
NewEmailUserAuthRenderData return the configured urls to redirect a user to the login, register or request password web pages
type HandlerWithEmailRegistration ¶
type HandlerWithEmailRegistration func(*gin.Context, *ActionPaths)
HandlerWithEmailRegistration is a handler that takes an extra ActionPaths param to be able to complete its operations (like sending an email with a password reset url).
type LoginPayload ¶
type LoginPayload struct { Email string `form:"username" binding:"required"` Password string `form:"password" binding:"required"` NextPage string `form:"nextpage"` }
LoginPayload contains the data required to log in a user.
type OKRes ¶
type OKRes struct {
Success bool `json:"success"`
}
OKRes has the result for a successful operation.
type RegisterPayload ¶
type RegisterPayload struct { Email string `form:"email" binding:"required"` Password string `form:"password1" binding:"required"` PasswordRepeated string `form:"password2" binding:"required"` }
RegisterPayload contains the data to register a new user.
type RequestResetPasswordPayload ¶
type RequestResetPasswordPayload struct {
Email string `form:"email" binding:"required"`
}
RequestResetPasswordPayload contains the data to request a password reset for a user.
type ResetPasswordWithTokenPayload ¶
type ResetPasswordWithTokenPayload struct { Token string `form:"token" binding:"required"` Password string `form:"password" binding:"required"` }
ResetPasswordWithTokenPayload contains the data to create a new password for a user using a reset password token.