feat: room manager and pushed to login page route
This commit is contained in:
@@ -7,10 +7,15 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"sunshine.industries/some-automoderation/rooms"
|
||||
"sunshine.industries/some-automoderation/sessions"
|
||||
)
|
||||
|
||||
func registerLoginRoutes(templateFs *embed.FS, sessionSM sessions.SessionManagement) {
|
||||
func registerLoginRoutes(
|
||||
templateFs *embed.FS,
|
||||
sessionSM sessions.SessionManagement,
|
||||
rooms rooms.RoomManager,
|
||||
) {
|
||||
// login page
|
||||
http.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) {
|
||||
var templFile = "templates/login.gohtml"
|
||||
@@ -33,15 +38,23 @@ func registerLoginRoutes(templateFs *embed.FS, sessionSM sessions.SessionManagem
|
||||
pn := r.PostFormValue("personalName")
|
||||
pp := r.PostFormValue("personalPassword")
|
||||
|
||||
roomId := 1 // would be taken from rooms interface from redis
|
||||
room, err := rooms.Get(rn)
|
||||
if err != nil {
|
||||
log.Printf("/login/submit error getting room %s", rn)
|
||||
// return i guess
|
||||
} else {
|
||||
log.Printf("/login/submit found room %+v", room)
|
||||
}
|
||||
|
||||
roomId := "room-name-actually" // would be taken from rooms interface from redis
|
||||
// would be either taken from room info on correct person pass or created
|
||||
personId := 111
|
||||
id, err := sessionSM.Save(int64(roomId), int64(personId))
|
||||
id, err := sessionSM.Save(roomId, int64(personId))
|
||||
if err != nil {
|
||||
log.Printf("/login/submit > error saving session %s", err)
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "is is %d. room things %s & %s, personal things %s and %s", id, rn, rp, pn, pp)
|
||||
fmt.Fprintf(w, "is is %d. room things %s & %s, personal things %s and %s. \n found room %+v", id, rn, rp, pn, pp, room)
|
||||
// i suppose here i'll need to
|
||||
// a) check if room password OK
|
||||
// b) get room data
|
||||
|
||||
Reference in New Issue
Block a user