From a50fac7d52905f0d388d4a2dd6ef2b8461ebe657 Mon Sep 17 00:00:00 2001 From: RaviAnand Mohabir Date: Thu, 26 Oct 2023 23:50:04 +0200 Subject: [PATCH] feat: :sparkles: display user after login --- auth/routes.go | 2 ++ core/app.go | 8 ++++++-- lists/monthly.go | 2 -- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/auth/routes.go b/auth/routes.go index 7c098f9..4c8e8f5 100644 --- a/auth/routes.go +++ b/auth/routes.go @@ -56,5 +56,7 @@ func Callback(app *core.App) func(w http.ResponseWriter, r *http.Request) { user, _ := spotifyClient.CurrentUser(ctx) users.SaveUserToken(ctx, app, user.ID, token) + + app.Render.JSON(w, 200, user) } } diff --git a/core/app.go b/core/app.go index 63b10e8..f2293bc 100644 --- a/core/app.go +++ b/core/app.go @@ -5,16 +5,16 @@ import ( "net/http" "net/url" + mongodbstore "github.com/2-72/gorilla-sessions-mongodb" "github.com/go-chi/chi" "github.com/gorilla/sessions" "github.com/spf13/viper" + "github.com/unrolled/render" spotifyauth "github.com/zmb3/spotify/v2/auth" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "golang.org/x/oauth2" "gopkg.in/mgo.v2" - - mongodbstore "github.com/2-72/gorilla-sessions-mongodb" ) type App struct { @@ -24,6 +24,7 @@ type App struct { SpotifyOAuthConfig *oauth2.Config Mux *chi.Mux SessionStore sessions.Store + Render *render.Render } func (a App) Run() { @@ -81,12 +82,15 @@ func NewApp() *App { mux := NewMux() + r := render.New() + app := &App{ MongoClient: client, SpotifyAuth: auth, SpotifyOAuthConfig: authConfig, Mux: mux, SessionStore: store, + Render: r, } return app diff --git a/lists/monthly.go b/lists/monthly.go index 8570365..469b781 100644 --- a/lists/monthly.go +++ b/lists/monthly.go @@ -23,8 +23,6 @@ func SyncMonthlyList(ctx context.Context, app *core.App, user *models.User) (int playlistName := fmt.Sprintf("%d %d", beginningOfMonth.Year(), beginningOfMonth.Month()) - fmt.Println(playlistName) - var playlist *spotify.SimplePlaylist playlists, err := client.CurrentUsersPlaylists(ctx)