feat: SSE bs into room
This commit is contained in:
@@ -33,8 +33,13 @@ const authCookieName = "auth"
|
||||
const loginPath = "/login"
|
||||
type contextKey string
|
||||
|
||||
func getContextSession(ctx context.Context) sessions.SessionData {
|
||||
return ctx.Value(contextKey("session")).(sessions.SessionData)
|
||||
func getContextSession(ctx context.Context) (sessions.SessionData, bool) {
|
||||
val := ctx.Value(contextKey("session"))
|
||||
if val == nil {
|
||||
return sessions.SessionData{}, false
|
||||
} else {
|
||||
return ctx.Value(contextKey("session")).(sessions.SessionData), true
|
||||
}
|
||||
}
|
||||
|
||||
// checks sessionId from cookie
|
||||
@@ -77,7 +82,7 @@ func authedPageMiddleware(
|
||||
}
|
||||
|
||||
func renderLoginPage(w http.ResponseWriter) {
|
||||
var templFile = "templates/login.gohtml"
|
||||
templFile := "templates/login.gohtml"
|
||||
tmpl := template.Must(template.ParseFS(templateFs, templFile))
|
||||
err := tmpl.Execute(w, nil)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user