Skip to content

Commit 7a6d521

Browse files
committed
Use empty username for request if user is not logged in
1 parent 856e98e commit 7a6d521

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

webapp/template.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,12 @@ func (TemplateController) RequestTrack(c *gin.Context) {
162162

163163
trackId := c.PostForm("trackId")
164164

165+
username := ""
165166
loginSession := authentication.GetValidSessionFromCookie(c)
166-
if loginSession == nil || loginSession.User == nil {
167-
c.Redirect(http.StatusSeeOther, fmt.Sprintf("/login?redirectTo=/session/view/%s", joinId))
168-
return
167+
if loginSession != nil && loginSession.User != nil {
168+
username = loginSession.User.SpotifyDisplayName
169169
}
170170

171-
username := loginSession.User.SpotifyDisplayName
172-
173171
_, spotifeteError := listeningSession.RequestSong(*session, trackId, username)
174172
if spotifeteError == nil {
175173
c.Redirect(http.StatusSeeOther, "/session/view/"+joinId)

0 commit comments

Comments
 (0)