Documentation ¶
Index ¶
- Constants
- Variables
- func CreateActivationEmail(la *LocalProvider, user *fs.User) (*fs.Mail, error)
- func CreateConfirmationURL(baseURL, appKey string, user *fs.User) (string, error)
- func CreateRecoveryEmail(la *LocalProvider, user *fs.User) (*fs.Mail, error)
- func NewGithubAuthProvider(config fs.Map, redirectURL string) (fs.AuthProvider, error)
- func NewGoogleAuthProvider(config fs.Map, redirectURL string) (fs.AuthProvider, error)
- func NewLocalAuthProvider(config fs.Map, redirectURL string) (fs.AuthProvider, error)
- func SendConfirmationEmail(la *LocalProvider, logger logger.Logger, mail *fs.Mail)
- func ValidateConfirmationToken(token, key string) (uint64, error)
- func ValidateRegisterData(c context.Context, logger logger.Logger, dbClient db.Client, payload *Register) (err error)
- type Activation
- type Confirmation
- type GithubAccessTokenResponse
- type GithubAuthProvider
- type GithubUserResponse
- type GoogleAuthProvider
- type GoogleUserResponse
- type LocalProvider
- func (la *LocalProvider) Activate(c fs.Context, _ any) (*Activation, error)
- func (la *LocalProvider) Callback(c fs.Context) (user *fs.User, err error)
- func (la *LocalProvider) Init(db func() db.Client, appKey func() string, appName func() string, ...)
- func (la *LocalProvider) LocalLogin(c fs.Context, payload *LoginData) (_ *LoginResponse, err error)
- func (la *LocalProvider) Login(c fs.Context) (_ any, err error)
- func (la *LocalProvider) Name() string
- func (la *LocalProvider) Recover(c fs.Context, data *Recovery) (_ bool, err error)
- func (la *LocalProvider) RecoverCheck(c fs.Context, data *Confirmation) (_ bool, err error)
- func (la *LocalProvider) Register(c fs.Context, payload *Register) (*Activation, error)
- func (la *LocalProvider) ResetPassword(c fs.Context, data *ResetPassword) (_ bool, err error)
- func (la *LocalProvider) SendActivationLink(c fs.Context, data *Confirmation) (*Activation, error)
- type LoginData
- type LoginResponse
- type Recovery
- type Register
- type ResetPassword
Constants ¶
View Source
const ProviderGithub = "github"
View Source
const ProviderGoogle = "google"
View Source
const ProviderLocal = "local"
Variables ¶
View Source
var ( MSG_USER_SAVE_ERROR = "error saving user" MSG_USER_ACTIVATION_ERROR = "error activating user" MSG_INVALID_TOKEN = "invalid token" MSG_TOKEN_EXPIRED = "token expired" MSG_CREATE_ACTIVATION_MAIL_ERROR = "error while creating activation email" MSG_CREATEP_RECOVERY_MAIL_ERROR = "error while creating recovery email" MSG_INVALID_EMAIL = "invalid email" MSG_INVALID_PASSWORD = "invalid password" MSG_INVALID_LOGIN_OR_PASSWORD = "invalid login or password" MSG_USER_IS_INACTIVE = "user is inactive" MSG_INVALID_REGISTRATION = "username, email, password and confirm_password are required" MSG_SEND_ACTIVATION_EMAIL_ERROR = "error while sending activation email" MSG_MAILER_NOT_SET = "mailer is not set" MSG_CHECKING_USER_ERROR = "error checking user" MSG_USER_EXISTS = "user already exists" ERR_SAVE_USER = errors.InternalServerError(MSG_USER_SAVE_ERROR) ERR_INVALID_TOKEN = errors.BadRequest(MSG_INVALID_TOKEN) ERR_TOKEN_EXPIRED = errors.BadRequest(MSG_TOKEN_EXPIRED) ERR_INVALID_LOGIN = errors.UnprocessableEntity(MSG_INVALID_LOGIN_OR_PASSWORD) )
Functions ¶
func CreateActivationEmail ¶
func CreateConfirmationURL ¶
func CreateRecoveryEmail ¶
func NewGithubAuthProvider ¶
func NewGoogleAuthProvider ¶
func NewLocalAuthProvider ¶
func SendConfirmationEmail ¶
func SendConfirmationEmail(la *LocalProvider, logger logger.Logger, mail *fs.Mail)
Types ¶
type Activation ¶
type Activation struct {
Activation string `json:"activation"` // auto, manual, email, activated
}
type Confirmation ¶
type Confirmation struct {
Token string `json:"token"`
}
type GithubAuthProvider ¶
type GithubAuthProvider struct {
// contains filtered or unexported fields
}
func (*GithubAuthProvider) Login ¶
func (ga *GithubAuthProvider) Login(c fs.Context) (_ any, err error)
func (*GithubAuthProvider) Name ¶
func (ga *GithubAuthProvider) Name() string
func (*GithubAuthProvider) WithResources ¶
func (ga *GithubAuthProvider) WithResources(resource *fs.Resource)
type GithubUserResponse ¶
type GoogleAuthProvider ¶
type GoogleAuthProvider struct {
// contains filtered or unexported fields
}
func (*GoogleAuthProvider) Login ¶
func (as *GoogleAuthProvider) Login(c fs.Context) (_ any, err error)
func (*GoogleAuthProvider) Name ¶
func (as *GoogleAuthProvider) Name() string
type GoogleUserResponse ¶
type LocalProvider ¶
type LocalProvider struct {
// contains filtered or unexported fields
}
activationMethod: auto, manual, email
auto: user is activated automatically manual: user is activated manually by admin email: user is activated by email
func (*LocalProvider) Activate ¶
func (la *LocalProvider) Activate(c fs.Context, _ any) (*Activation, error)
func (*LocalProvider) LocalLogin ¶
func (la *LocalProvider) LocalLogin(c fs.Context, payload *LoginData) (_ *LoginResponse, err error)
func (*LocalProvider) Name ¶
func (la *LocalProvider) Name() string
func (*LocalProvider) RecoverCheck ¶
func (la *LocalProvider) RecoverCheck(c fs.Context, data *Confirmation) (_ bool, err error)
func (*LocalProvider) Register ¶
func (la *LocalProvider) Register(c fs.Context, payload *Register) (*Activation, error)
func (*LocalProvider) ResetPassword ¶
func (la *LocalProvider) ResetPassword(c fs.Context, data *ResetPassword) (_ bool, err error)
func (*LocalProvider) SendActivationLink ¶
func (la *LocalProvider) SendActivationLink(c fs.Context, data *Confirmation) (*Activation, error)
type LoginResponse ¶
type Register ¶
type ResetPassword ¶
type ResetPassword struct { *Confirmation Password string `json:"password"` ConfirmPassword string `json:"confirm_password"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.