refactor(web): make a separate auth middlewares for server
also slightly change api auth middleware
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func middlewareAuth(c *gin.Context) {
|
||||
user_id := c.GetString("user_id")
|
||||
if user_id == "" {
|
||||
c.Redirect(http.StatusSeeOther, "/")
|
||||
return
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
Reference in New Issue
Block a user