feat: go to room on create/login
This commit is contained in:
parent
cdd31e186a
commit
8bb1509786
|
@ -131,10 +131,10 @@ func createRoomHandler(templateFs *embed.FS,
|
|||
PasswordHash: r.PostFormValue("personalPassword"), // TODO hash the password, not to store
|
||||
}
|
||||
newRoom := rooms.Room{
|
||||
Name: roomName,
|
||||
PasswordHash: r.PostFormValue("roomPassword"), // TODO hash the password, not to store
|
||||
AdminIds: []rooms.PersonId{person.Id},
|
||||
Paricipants: []rooms.PersonId{person.Id},
|
||||
Name: roomName,
|
||||
PasswordHash: r.PostFormValue("roomPassword"), // TODO hash the password, not to store
|
||||
AdminIds: []rooms.PersonId{person.Id},
|
||||
Paricipants: []rooms.PersonId{person.Id},
|
||||
AllKnownPeople: map[rooms.PersonId]rooms.Person{
|
||||
person.Id: person},
|
||||
}
|
||||
|
@ -155,9 +155,7 @@ func createRoomHandler(templateFs *embed.FS,
|
|||
HttpOnly: true,
|
||||
Path: "/",
|
||||
})
|
||||
w.Header().Add("HX-Retarget", "body")
|
||||
w.Header().Add("HX-Push-Url", "/")
|
||||
renderIndexPage(newSession, w)
|
||||
w.Header().Add("HX-Redirect", fmt.Sprintf("/room/%s", newRoom.Name))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,7 +241,7 @@ func joinRoomHandler(templateFs *embed.FS,
|
|||
err := roomsM.Update(r.Context(), room.Name, func(fromRoom rooms.Room) (toRoom rooms.Room) {
|
||||
log.Printf("/login/join about to modify room %+v", fromRoom)
|
||||
toRoom = fromRoom
|
||||
toRoom.AllKnownPeople[person.Id] = person
|
||||
toRoom.AllKnownPeople[person.Id] = person
|
||||
log.Printf("/login/join will save %+v", toRoom)
|
||||
return toRoom
|
||||
})
|
||||
|
@ -275,23 +273,23 @@ func joinRoomHandler(templateFs *embed.FS,
|
|||
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 {
|
||||
log.Printf("/login/submit > error saving session %s", err)
|
||||
}
|
||||
http.SetCookie(w, &http.Cookie{
|
||||
Name: authCookieName,
|
||||
Value: fmt.Sprint(newSessionId),
|
||||
Value: fmt.Sprint(newSession.SessionId),
|
||||
Secure: true,
|
||||
HttpOnly: true,
|
||||
Path: "/",
|
||||
})
|
||||
log.Printf("is is %d. room things %s & %s, personal things %s and %s. \n found room %+v",
|
||||
newSessionId, roomName, roomPass, personName, personPass, room,
|
||||
log.Printf("is is %+v. room things %s & %s, personal things %s and %s. \n found room %+v",
|
||||
newSession, roomName, roomPass, personName, personPass, room,
|
||||
)
|
||||
// TODO render what? index page with some data passed?
|
||||
// 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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue