add logout and better redirects
This commit is contained in:
1 parent
106c24546e
commit
6257cb2bcb
6 files changed
+88
-23
No files matched your search
@@ -2,6 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
@@ -247,3 +248,18 @@ func Login(c *fiber.Ctx) error {
|
||||
|
||||
return c.Status(fiber.StatusNotImplemented).Redirect("/dashboard")
|
||||
}
|
||||
|
||||
func Logout(c *fiber.Ctx) error {
|
||||
fmt.Println("here")
|
||||
cookie := fiber.Cookie{
|
||||
Name: "jwt",
|
||||
Value: "",
|
||||
Expires: time.Now().Add(-time.Hour),
|
||||
HTTPOnly: true,
|
||||
}
|
||||
c.Cookie(&cookie)
|
||||
|
||||
return c.Status(fiber.StatusOK).Render("index", fiber.Map{
|
||||
"loggedIn": false,
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user