mirror of
https://github.com/linux-do/new-api.git
synced 2025-11-13 09:33:43 +08:00
merge upstream
Signed-off-by: wozulong <>
This commit is contained in:
@@ -74,6 +74,17 @@ func authHelper(c *gin.Context, minRole int) {
|
||||
c.Next()
|
||||
}
|
||||
|
||||
func TryUserAuth() func(c *gin.Context) {
|
||||
return func(c *gin.Context) {
|
||||
session := sessions.Default(c)
|
||||
id := session.Get("id")
|
||||
if id != nil {
|
||||
c.Set("id", id)
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
func UserAuth() func(c *gin.Context) {
|
||||
return func(c *gin.Context) {
|
||||
authHelper(c, common.RoleCommonUser)
|
||||
|
||||
Reference in New Issue
Block a user