feat: go to room on create/login

This commit is contained in:
efim 2023-11-18 04:07:13 +00:00
parent cdd31e186a
commit 8bb1509786
1 changed files with 11 additions and 13 deletions

View File

@ -155,9 +155,7 @@ func createRoomHandler(templateFs *embed.FS,
HttpOnly: true, HttpOnly: true,
Path: "/", Path: "/",
}) })
w.Header().Add("HX-Retarget", "body") w.Header().Add("HX-Redirect", fmt.Sprintf("/room/%s", newRoom.Name))
w.Header().Add("HX-Push-Url", "/")
renderIndexPage(newSession, w)
} }
} }
@ -275,23 +273,23 @@ func joinRoomHandler(templateFs *embed.FS,
return // error sitting a new person return // error sitting a new person
} }
newSessionId, err := sessionSM.Save(r.Context(), room.Name, person.Id) newSession, err := sessionSM.Save(r.Context(), room.Name, person.Id)
if err != nil { if err != nil {
log.Printf("/login/submit > error saving session %s", err) log.Printf("/login/submit > error saving session %s", err)
} }
http.SetCookie(w, &http.Cookie{ http.SetCookie(w, &http.Cookie{
Name: authCookieName, Name: authCookieName,
Value: fmt.Sprint(newSessionId), Value: fmt.Sprint(newSession.SessionId),
Secure: true, Secure: true,
HttpOnly: true, HttpOnly: true,
Path: "/", Path: "/",
}) })
log.Printf("is is %d. room things %s & %s, personal things %s and %s. \n found room %+v", log.Printf("is is %+v. room things %s & %s, personal things %s and %s. \n found room %+v",
newSessionId, roomName, roomPass, personName, personPass, room, newSession, roomName, roomPass, personName, personPass, room,
) )
// TODO render what? index page with some data passed? // TODO render what? index page with some data passed?
// or, what? i could just redirect to / for now // or, what? i could just redirect to / for now
w.Header().Add("HX-Redirect", "/") w.Header().Add("HX-Redirect", fmt.Sprintf("/room/%s", newSession.RoomId))
} }
} }