diff --git a/server.go b/server.go index 4edd392..a98189c 100644 --- a/server.go +++ b/server.go @@ -173,15 +173,24 @@ func getNew(c *fiber.Ctx) error { } func mytoken(c *fiber.Ctx) error { + //if c.Query("error") return c.BodyParser(&SpotifyAPI) } +func spotifyCallback(c *fiber.Ctx) error { + if c.Query("error") != "" { + return c.Render("index", fiber.Map{"error": "Erreur lors de la connexion.",}) + } else { + return c.Render("spotify-token", fiber.Map{}) + } +} + func index(c *fiber.Ctx) error { return c.Render("index", fiber.Map{"connected": !SpotifyAPI.CheckEmpty(),}) } func main() { - //app := fiber.New(fiber.Config(Views: html, ViewsLayout: "layouts/mainbbb")) + //app := fiber.New(fiber.Config(Views: html, ViewsLayout: "layouts/main")) app := fiber.New(fiber.Config{Views: html.New("./views", ".html"),}) app.Static("/", "./static") @@ -189,6 +198,7 @@ func main() { app.Get("/hello", hello) app.Get("/refresh", getNew) app.Get("/spotify", loginSpotify) + app.Get("/callback", spotifyCallback) app.Post("/back", formHandler) app.Post("/mytoken", mytoken) diff --git a/views/spotify-token.html b/views/spotify-token.html new file mode 100644 index 0000000..163b0b9 --- /dev/null +++ b/views/spotify-token.html @@ -0,0 +1 @@ +