fix: display correct button on unauthed room page
This commit is contained in:
parent
f7def011f5
commit
550841e882
|
@ -34,7 +34,7 @@ func registerLoginRoutes(
|
|||
) {
|
||||
// login page
|
||||
http.HandleFunc(loginPath, func(w http.ResponseWriter, r *http.Request) {
|
||||
renderLoginPage(w, "")
|
||||
renderLoginPage(w, "", false)
|
||||
})
|
||||
http.HandleFunc("/login/join", joinRoomHandler(templateFs, sessionSM, roomsM))
|
||||
http.HandleFunc("/login/create", createRoomHandler(templateFs, sessionSM, roomsM))
|
||||
|
@ -107,7 +107,7 @@ func authedPageMiddleware(
|
|||
})
|
||||
}
|
||||
|
||||
func renderLoginPage(w http.ResponseWriter, roomName string) {
|
||||
func renderLoginPage(w http.ResponseWriter, roomName string, isRoomExisting bool) {
|
||||
baseFile := "templates/base.gohtml"
|
||||
pageTempl := "templates/login.gohtml"
|
||||
loginSecion := "templates/login-section.gohtml"
|
||||
|
@ -123,7 +123,7 @@ func renderLoginPage(w http.ResponseWriter, roomName string) {
|
|||
},
|
||||
Content: loginPageData{
|
||||
LoginSection: LoginSectionData{
|
||||
IsRoomExisting: false,
|
||||
IsRoomExisting: isRoomExisting,
|
||||
RoomName: roomName,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -177,13 +177,13 @@ func roomPageRoute(
|
|||
|
||||
// check session,
|
||||
session, err := getRequestSession(r, sessionSM)
|
||||
room, found, err := roomsM.Get(roomName)
|
||||
if err != nil || session.RoomId != roomName {
|
||||
log.Printf("not authed with session %+v | error %s, but for wrong room, trying to access %s", session, err, roomName)
|
||||
renderLoginPage(w, roomName)
|
||||
renderLoginPage(w, roomName, found)
|
||||
return
|
||||
}
|
||||
|
||||
room, found, err := roomsM.Get(roomName)
|
||||
if err != nil || !found {
|
||||
log.Printf("/room room for name %s not found or err: %s / found %t", roomName, err, found)
|
||||
// TODO here should be append to error place
|
||||
|
|
Loading…
Reference in New Issue