middleware

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

ProviderSetMiddleware is providers.

Functions

func ExtractAndSetAcceptLanguage added in v1.0.0

func ExtractAndSetAcceptLanguage(ctx *gin.Context)

ExtractAndSetAcceptLanguage extract accept language from header and set to context

func ExtractToken

func ExtractToken(ctx *gin.Context) (token string)

ExtractToken extract token from context

func GetIsAdminFromContext added in v0.4.2

func GetIsAdminFromContext(ctx *gin.Context) (isAdmin bool)

GetIsAdminFromContext get user is admin from context

func GetLoginUserIDFromContext

func GetLoginUserIDFromContext(ctx *gin.Context) (userID string)

GetLoginUserIDFromContext get user id from context

func GetLoginUserIDInt64FromContext

func GetLoginUserIDInt64FromContext(ctx *gin.Context) (userID int64)

func GetUserInfoFromContext

func GetUserInfoFromContext(ctx *gin.Context) (u *entity.UserCacheInfo)

GetUserInfoFromContext get user info from context

Types

type AuthUserMiddleware

type AuthUserMiddleware struct {
	// contains filtered or unexported fields
}

AuthUserMiddleware auth user middleware

func NewAuthUserMiddleware

func NewAuthUserMiddleware(
	authService *auth.AuthService,
	siteInfoCommonService *siteinfo_common.SiteInfoCommonService) *AuthUserMiddleware

NewAuthUserMiddleware new auth user middleware

func (*AuthUserMiddleware) AdminAuth added in v1.0.1

func (am *AuthUserMiddleware) AdminAuth() gin.HandlerFunc

func (*AuthUserMiddleware) Auth

func (am *AuthUserMiddleware) Auth() gin.HandlerFunc

Auth get token and auth user, set user info to context if user is already login

func (*AuthUserMiddleware) EjectUserBySiteInfo added in v1.0.0

func (am *AuthUserMiddleware) EjectUserBySiteInfo() gin.HandlerFunc

EjectUserBySiteInfo if admin config the site can access by nologin user, eject user.

func (*AuthUserMiddleware) MustAuth

func (am *AuthUserMiddleware) MustAuth() gin.HandlerFunc

MustAuth auth user info. If the user does not log in, an unauthenticated error is displayed

type AvatarMiddleware

type AvatarMiddleware struct {
	// contains filtered or unexported fields
}

func NewAvatarMiddleware

func NewAvatarMiddleware(serviceConfig *service_config.ServiceConfig,
	uploaderService *uploader.UploaderService,
) *AvatarMiddleware

NewAvatarMiddleware new auth user middleware

func (*AvatarMiddleware) AvatarThumb

func (am *AvatarMiddleware) AvatarThumb() gin.HandlerFunc

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL