Documentation
¶
Index ¶
- Constants
- func AllowReadCharacter(u Auth, c model.Character) bool
- func AllowReadSubject(u Auth, s model.Subject) bool
- func CanViewClosedTopic(a Auth) bool
- func CanViewDeleteTopic(a Auth) bool
- func CanViewTopicContent(u Auth, topic model.Topic) bool
- func ListTopicDisplays(u Auth) []model.TopicDisplay
- func RewriteCommentTree(comments []model.Comment) []model.Comment
- func RewriteCommit(t model.Comment) model.Comment
- func RewriteSubCommit(t model.SubComment) model.SubComment
- type AccessToken
- type Auth
- type Permission
- type Repo
- type Service
- type TokenInfo
- type UserInfo
Constants ¶
View Source
const ( UserGroupAdmin uint8 = iota + 1 UserGroupBangumiAdmin UserGroupWindowAdmin UserGroupQuite UserGroupBanned UserGroupCharacterAdmin UserGroupWikiAdmin UserGroupNormal UserGroupWikiEditor )
View Source
const CanViewStateClosedTopic = gtime.OneDay * 180
View Source
const CanViewStateDeleteTopic = gtime.OneDay * 365
View Source
const TokenTypeAccessToken = 1
View Source
const TokenTypeOauthToken = 0
Variables ¶
This section is empty.
Functions ¶
func CanViewClosedTopic ¶ added in v0.22.0
func CanViewDeleteTopic ¶ added in v0.22.0
func CanViewTopicContent ¶ added in v0.22.0
func ListTopicDisplays ¶ added in v0.25.9
func ListTopicDisplays(u Auth) []model.TopicDisplay
ListTopicDisplays 在帖子列表能看到哪些状态的帖子。
func RewriteCommentTree ¶ added in v0.23.2
func RewriteSubCommit ¶ added in v0.22.0
func RewriteSubCommit(t model.SubComment) model.SubComment
Types ¶
type AccessToken ¶ added in v0.30.3
type Auth ¶ added in v0.30.3
type Auth struct {
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.