@@ -8,12 +8,6 @@ import (
8
8
"github.com/gofiber/fiber/v2/middleware/session"
9
9
)
10
10
11
- func loginData (flash string ) fiber.Map {
12
- return fiber.Map {
13
- "Flash" : flash ,
14
- }
15
- }
16
-
17
11
func Login (c * fiber.Ctx , cc core.Context ) error {
18
12
return h .Render (c , "login" , fiber.Map {})
19
13
}
@@ -60,51 +54,8 @@ func Logout(c *fiber.Ctx, cc core.Context, store *session.Store) error {
60
54
return h .Redirect (c , "/login" )
61
55
}
62
56
63
- func UserRequire (c * fiber.Ctx , cc core.Context , store * session.Store ) error {
64
- if procs .AuthHTTPAnonymous (cc ) {
65
- return NotFound (c )
66
- }
67
-
68
- return authRequire (c , cc , store )
69
- }
70
-
71
- func AuthRequire (c * fiber.Ctx , cc core.Context , store * session.Store ) error {
72
- if procs .AuthHTTPAnonymous (cc ) {
73
- c .Locals (h .AnonymousContextKey , true )
74
- return c .Next ()
75
- }
76
-
77
- return authRequire (c , cc , store )
78
- }
79
-
80
- func authRequire (c * fiber.Ctx , cc core.Context , store * session.Store ) error {
81
- sess , err := store .Get (c )
82
- if err != nil {
83
- panic (err )
84
- }
85
-
86
- auth := sess .Get ("auth" )
87
- if auth == nil {
88
- return h .Redirect (c , "/login" )
89
- }
90
-
91
- return c .Next ()
92
- }
93
-
94
- func AuthRestrict (c * fiber.Ctx , cc core.Context , store * session.Store ) error {
95
- if procs .AuthHTTPAnonymous (cc ) {
96
- return h .Redirect (c , "/" )
97
- }
98
-
99
- sess , err := store .Get (c )
100
- if err != nil {
101
- return h .Error (c , err )
102
- }
103
-
104
- auth := sess .Get ("auth" )
105
- if auth != nil {
106
- return h .Redirect (c , "/" )
57
+ func loginData (flash string ) fiber.Map {
58
+ return fiber.Map {
59
+ "Flash" : flash ,
107
60
}
108
-
109
- return c .Next ()
110
61
}
0 commit comments