Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LoginInput ¶
type LoginInput struct { Email string `json:"email,omitempty"` MemberName string `json:"membername,omitempty"` Password string `json:"password"` SessionTime int32 `json:"session_time" default:"30"` // in minutes. Setting to 2^31-1 is used to keep user signed in }
LoginInput is the input for the login request
type RegLoginInput ¶
type RegLoginInput interface { RegisterInput | LoginInput }
RegLoginInput is an union (feature introduced in Go 1.18) of RegisterInput and LoginInput
type RegisterInput ¶
type RegisterInput struct { Email string `json:"email"` MemberName string `json:"membername"` // Password is first temporarily encrypted using RSA and then hashed using argon2id // For more details see the internal/crypt package Password string `json:"password"` PasswordConfirm string `json:"passwordConfirm"` Roles []string `json:"roles"` }
RegisterInput is the input for the registration request
type Service ¶ added in v0.6.2
type Service struct {
// contains filtered or unexported fields
}
Service allows dependency injection for the controller methods, so that the db connection needn't be created in the controller methods
func NewService ¶ added in v0.6.2
func NewService( conf *cfg.Config, ms member.Storer, log *zerolog.Logger, sess *session.Store, ) *Service
NewService creates an instance of the Service struct and returns a pointer to it It should be used within the routes package where the db connection and config are passed from the main package
func (*Service) ChangePassword ¶ added in v0.9.10
@Summary Change password @Description Change the password for the currently logged in user @Tags auth,accounts,updating,settings @Accept json @Produce json @Param old body string true "The old password" @Param new body string true "The new password" @Param X-CSRF-Token header string true "CSRF protection token" @Param Authorization header string true "JWT token" @Router /authenticate/password [patch]
func (*Service) DeleteAccount ¶ added in v0.9.10
@Summary Delete account @Description Delete the account of the currently logged in user @Tags auth,accounts,deleting,settings @Accept json @Param password body string true "The password" @Param confirmation body string true "Confirmation of the password" @Param X-CSRF-Token header string true "CSRF protection token" @Param Authorization header string true "JWT token" @Router /authenticate/delete-account [post]
func (*Service) GetAuthStatus ¶ added in v0.7.0
func (*Service) Login ¶ added in v0.6.2
1. Parse the input 2. Validate the input (check for empty fields, valid email, etc.) 3. Pass the email to the database, get the password hash for the email or nickname 4. Compare the password hash with the password hash from the database @Summary Login to the application @Description Create a session for the user @Tags auth,accounts @Accept multipart/form-data @Produce json @Param membername query string false "Member name. Request must include either membername or email" @Param email query string false "Email address" @Param session_time query int false "Session time in minutes" default(30) minimum(1) maximum(2147483647) @Param password query string true "Password" @Param Referrer-Policy header string false "Referrer-Policy header" "no-referrer-when-downgrade" @Param X-CSRF-Token header string true "X-CSRF-Token header" @Success 200 {object} h.ResponseHTTP{data=SessionResponse} @Failure 400 {object} h.ResponseHTTP{} @Failure 401 {object} h.ResponseHTTP{} @Failure 500 {object} h.ResponseHTTP{} @Router /authenticate/login [post]