|
@@ -2,11 +2,11 @@ package router
|
|
|
|
|
|
import (
|
|
|
"encoding/gob"
|
|
|
- "net/http"
|
|
|
"time"
|
|
|
|
|
|
"github.com/gin-contrib/sessions"
|
|
|
"github.com/gin-contrib/sessions/cookie"
|
|
|
+
|
|
|
//"github.com/gin-contrib/sessions/memstore"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"gopkg.in/mgo.v2/bson"
|
|
@@ -22,18 +22,3 @@ func init() {
|
|
|
gob.Register(&time.Time{})
|
|
|
gob.Register(bson.ObjectIdHex("518781f5904a2ea61544f852"))
|
|
|
}
|
|
|
-
|
|
|
-func AuthMiddleWare() gin.HandlerFunc {
|
|
|
- return func(c *gin.Context) {
|
|
|
- session := sessions.Default(c)
|
|
|
- if session.Get("user") != nil {
|
|
|
- c.Next()
|
|
|
- return
|
|
|
- }
|
|
|
- c.JSON(http.StatusUnauthorized, gin.H{
|
|
|
- "error": "Unauthorized",
|
|
|
- })
|
|
|
- c.Abort()
|
|
|
- return
|
|
|
- }
|
|
|
-}
|