Documentation ¶
Index ¶
Constants ¶
View Source
const ( UserGroupAdmin uint8 = iota + 1 UserGroupBangumiAdmin UserGroupWindowAdmin UserGroupQuite UserGroupBanned UserGroupCharacterAdmin UserGroupWikiAdmin UserGroupNormal UserGroupWikiEditor )
View Source
const TokenTypeAccessToken = 1
View Source
const TokenTypeOauthToken = 0
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccessToken ¶ added in v0.30.3
type Auth ¶ added in v0.30.3
type Auth struct { Login bool RegTime time.Time ID model.UserID // user id GroupID user.GroupID Permission Permission `json:"-"` // disable cache for this field. }
Auth is the basic authorization represent a user.
type Permission ¶ added in v0.30.3
type Permission struct { UserList bool ManageUserGroup bool ManageUserPhoto bool ManageTopicState bool ManageReport bool UserBan bool ManageUser bool UserGroup bool UserWikiApply bool `doc:"申请 wiki 人"` UserWikiApprove bool DoujinSubjectErase bool DoujinSubjectLock bool SubjectEdit bool SubjectLock bool SubjectRefresh bool SubjectRelated bool SubjectMerge bool SubjectErase bool SubjectCoverLock bool SubjectCoverErase bool MonoEdit bool MonoLock bool MonoMerge bool MonoErase bool BanPost bool EpEdit bool EpMove bool EpMerge bool EpLock bool EpErase bool Report bool ManageApp bool AppErase bool }
type Repo ¶ added in v0.30.3
type Repo interface { // GetByToken return an authorized user by a valid access token. GetByToken(ctx context.Context, token string) (UserInfo, error) GetPermission(ctx context.Context, groupID uint8) (Permission, error) CreateAccessToken( ctx context.Context, userID model.UserID, name string, expiration time.Duration, ) (token string, err error) ListAccessToken(ctx context.Context, userID model.UserID) ([]AccessToken, error) DeleteAccessToken(ctx context.Context, tokenID uint32) (bool, error) // GetByEmail return (Auth, HashedPassword, error) GetByEmail(ctx context.Context, email string) (UserInfo, []byte, error) GetTokenByID(ctx context.Context, id uint32) (AccessToken, error) }
AuthRepo presents an authorization.
type Service ¶ added in v0.30.3
type Service interface { GetByToken(ctx context.Context, token string) (Auth, error) GetByID(ctx context.Context, userID model.UserID) (Auth, error) ComparePassword(hashed []byte, password string) (bool, error) Login(ctx context.Context, email, password string) (Auth, bool, error) GetTokenByID(ctx context.Context, tokenID uint32) (AccessToken, error) CreateAccessToken( ctx context.Context, userID model.UserID, name string, expiration time.Duration, ) (token string, err error) ListAccessToken(ctx context.Context, userID model.UserID) ([]AccessToken, error) DeleteAccessToken(ctx context.Context, tokenID uint32) (bool, error) }
func NewService ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.