feat: display user after login
continuous-integration/drone/push Build is failing Details

main
RaviAnand Mohabir 11 months ago
parent a1ae73f9cb
commit a50fac7d52

@ -56,5 +56,7 @@ func Callback(app *core.App) func(w http.ResponseWriter, r *http.Request) {
user, _ := spotifyClient.CurrentUser(ctx) user, _ := spotifyClient.CurrentUser(ctx)
users.SaveUserToken(ctx, app, user.ID, token) users.SaveUserToken(ctx, app, user.ID, token)
app.Render.JSON(w, 200, user)
} }
} }

@ -5,16 +5,16 @@ import (
"net/http" "net/http"
"net/url" "net/url"
mongodbstore "github.com/2-72/gorilla-sessions-mongodb"
"github.com/go-chi/chi" "github.com/go-chi/chi"
"github.com/gorilla/sessions" "github.com/gorilla/sessions"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/unrolled/render"
spotifyauth "github.com/zmb3/spotify/v2/auth" spotifyauth "github.com/zmb3/spotify/v2/auth"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"
"golang.org/x/oauth2" "golang.org/x/oauth2"
"gopkg.in/mgo.v2" "gopkg.in/mgo.v2"
mongodbstore "github.com/2-72/gorilla-sessions-mongodb"
) )
type App struct { type App struct {
@ -24,6 +24,7 @@ type App struct {
SpotifyOAuthConfig *oauth2.Config SpotifyOAuthConfig *oauth2.Config
Mux *chi.Mux Mux *chi.Mux
SessionStore sessions.Store SessionStore sessions.Store
Render *render.Render
} }
func (a App) Run() { func (a App) Run() {
@ -81,12 +82,15 @@ func NewApp() *App {
mux := NewMux() mux := NewMux()
r := render.New()
app := &App{ app := &App{
MongoClient: client, MongoClient: client,
SpotifyAuth: auth, SpotifyAuth: auth,
SpotifyOAuthConfig: authConfig, SpotifyOAuthConfig: authConfig,
Mux: mux, Mux: mux,
SessionStore: store, SessionStore: store,
Render: r,
} }
return app return app

@ -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()) playlistName := fmt.Sprintf("%d %d", beginningOfMonth.Year(), beginningOfMonth.Month())
fmt.Println(playlistName)
var playlist *spotify.SimplePlaylist var playlist *spotify.SimplePlaylist
playlists, err := client.CurrentUsersPlaylists(ctx) playlists, err := client.CurrentUsersPlaylists(ctx)

Loading…
Cancel
Save