update(error): front error during Spotify connection

(#6)
This commit is contained in:
rick 2021-09-09 15:06:11 +02:00
parent 7d259ceef8
commit 8edd16e6ab
Signed by: Rick
GPG key ID: 2B593F087240EE99
2 changed files with 12 additions and 1 deletions

View file

@ -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)

1
views/spotify-token.html Normal file
View file

@ -0,0 +1 @@
<script src="/gethash.js"></script>