Documentation ¶
Index ¶
- Variables
- type Token
- type User
- func (u *User) Active(ctx context.Context, token string) *gm.Error
- func (u *User) ChangePassword(_ context.Context, email, oldPass, newPass string) *gm.Error
- func (u *User) ResetPassword(ctx context.Context, password, token string) *gm.Error
- func (u *User) SendMail(ctx context.Context, email, emailType, url string) error
- func (u *User) SignIn(_ context.Context, user *model.User) (*model.User, *gm.Error)
- func (u *User) SignInByOauth2(ctx context.Context, source, code string) (*model.User, *gm.Error)
- func (u *User) SignUp(ctx context.Context, url string, user *model.User) *gm.Error
- type UserOption
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUserExists 需要注册的用户已经存在了 ErrUserExists = gm.NewError(http.StatusConflict, 40101, "email exists") // ErrUserSignIn 用户名或密码错误 ErrUserSignIn = gm.NewError(http.StatusBadRequest, 40102, "username or password incorrect") // ErrOauth2Source 未知的 oauth2 认证源 ErrOauth2Source = gm.NewError(http.StatusBadRequest, 40103, "unknown oauth2 source") // ErrOauth2State oauth2 state 校验失败 ErrOauth2State = gm.NewError(http.StatusBadRequest, 40104, "incorrect state") // ErrActive 无效或已过期的激活链接 ErrActive = gm.NewError(http.StatusBadRequest, 40105, "invalid or expired active link") // ErrOldPassword 老密码错误 ErrOldPassword = gm.NewError(http.StatusBadRequest, 40106, "invalid password") // ErrResetPassword 重置密码错误 ErrResetPassword = gm.NewError(http.StatusBadRequest, 40107, "reset password") // ErrOauth2ExchangeCode 获取 access token err ErrOauth2ExchangeCode = gm.NewError(http.StatusServiceUnavailable, 60101, "oauth2 exchange code") // ErrGetOauth2User 获取 oauth2 用户信息 ErrGetOauth2User = gm.NewError(http.StatusServiceUnavailable, 60102, "get oauth2 user info") )
Functions ¶
This section is empty.
Types ¶
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token srv
func (*Token) GetToken ¶
GetToken 获取 access token,自动刷新
type User ¶
type User struct {
// contains filtered or unexported fields
}
User 用户数据服务
func (*User) Active ¶
Active 注册激活
func (*User) ChangePassword ¶
ChangePassword 更新密码
func (*User) ResetPassword ¶
ResetPassword 重置密码
func (*User) SendMail ¶
SendMail 发送注册激活、重置密码邮件
func (*User) SignIn ¶
SignIn 用户登录
func (*User) SignInByOauth2 ¶
SignInByOauth2 oauth2 登录
Click to show internal directories.
Click to hide internal directories.