@@ -16,7 +16,7 @@ func Login(c *fiber.Ctx, cc core.Context) error {
16
16
return c .Render ("login" , LoginData {})
17
17
}
18
18
19
- func AuthLogin (c * fiber.Ctx , cc core.Context , store * session.Store ) error {
19
+ func LoginPost (c * fiber.Ctx , cc core.Context , store * session.Store ) error {
20
20
// Request
21
21
username := c .FormValue ("username" )
22
22
password := c .FormValue ("password" )
@@ -44,7 +44,7 @@ func AuthLogin(c *fiber.Ctx, cc core.Context, store *session.Store) error {
44
44
return helpers .Redirect (c , "/" )
45
45
}
46
46
47
- func AuthLogout (c * fiber.Ctx , cc core.Context , store * session.Store ) error {
47
+ func Logout (c * fiber.Ctx , cc core.Context , store * session.Store ) error {
48
48
sess , err := store .Get (c )
49
49
if err != nil {
50
50
return helpers .Error (c , err )
@@ -58,11 +58,23 @@ func AuthLogout(c *fiber.Ctx, cc core.Context, store *session.Store) error {
58
58
return helpers .Redirect (c , "/login" )
59
59
}
60
60
61
+ func UserRequire (c * fiber.Ctx , cc core.Context , store * session.Store ) error {
62
+ if procs .AuthHTTPAnonymous (cc ) {
63
+ return helpers .NotFound (c )
64
+ }
65
+
66
+ return authRequire (c , cc , store )
67
+ }
68
+
61
69
func AuthRequire (c * fiber.Ctx , cc core.Context , store * session.Store ) error {
62
70
if procs .AuthHTTPAnonymous (cc ) {
63
71
return c .Next ()
64
72
}
65
73
74
+ return authRequire (c , cc , store )
75
+ }
76
+
77
+ func authRequire (c * fiber.Ctx , cc core.Context , store * session.Store ) error {
66
78
sess , err := store .Get (c )
67
79
if err != nil {
68
80
panic (err )
@@ -76,7 +88,7 @@ func AuthRequire(c *fiber.Ctx, cc core.Context, store *session.Store) error {
76
88
return c .Next ()
77
89
}
78
90
79
- func AuthSkip (c * fiber.Ctx , cc core.Context , store * session.Store ) error {
91
+ func AuthRestrict (c * fiber.Ctx , cc core.Context , store * session.Store ) error {
80
92
if procs .AuthHTTPAnonymous (cc ) {
81
93
return helpers .Redirect (c , "/" )
82
94
}
0 commit comments