diff --git a/internal/api/members/controler.go b/internal/api/members/controler.go index 73fcea0e..42371216 100644 --- a/internal/api/members/controler.go +++ b/internal/api/members/controler.go @@ -42,11 +42,6 @@ func (h *MembersHandler) membersCreate(w http.ResponseWriter, r *http.Request) { return } - if data.Secret == "" { - utils.HttpBadRequest(w, "Secret cannot be empty.") - return - } - if data.Name == "" { utils.HttpBadRequest(w, "Name cannot be empty.") return diff --git a/internal/api/session.go b/internal/api/session.go index 9fc5b001..7526b838 100644 --- a/internal/api/session.go +++ b/internal/api/session.go @@ -14,11 +14,11 @@ var CookieExpirationDate = time.Now().Add(365 * 24 * time.Hour) var UnsecureCookies = os.Getenv("DISABLE_SECURE_COOKIES") == "true" type SessionLoginPayload struct { - ID string `json:"id"` - Secret string `json:"secret"` + Username string `json:"username"` + Password string `json:"password"` } -type SessionWhoamiPayload struct { +type SessionDataPayload struct { ID string `json:"id"` Profile types.MemberProfile `json:"profile"` State types.SessionState `json:"state"` @@ -31,8 +31,8 @@ func (api *ApiManagerCtx) Login(w http.ResponseWriter, r *http.Request) { } // TODO: Proper login. - session, token, err := api.sessions.Create(data.ID, types.MemberProfile{ - Name: data.ID, + session, token, err := api.sessions.Create(data.Username, types.MemberProfile{ + Name: data.Username, IsAdmin: true, CanLogin: true, CanConnect: true, @@ -60,7 +60,7 @@ func (api *ApiManagerCtx) Login(w http.ResponseWriter, r *http.Request) { HttpOnly: true, }) - utils.HttpSuccess(w, SessionWhoamiPayload{ + utils.HttpSuccess(w, SessionDataPayload{ ID: session.ID(), Profile: session.GetProfile(), State: session.GetState(), @@ -97,7 +97,7 @@ func (api *ApiManagerCtx) Logout(w http.ResponseWriter, r *http.Request) { func (api *ApiManagerCtx) Whoami(w http.ResponseWriter, r *http.Request) { session := auth.GetSession(r) - utils.HttpSuccess(w, SessionWhoamiPayload{ + utils.HttpSuccess(w, SessionDataPayload{ ID: session.ID(), Profile: session.GetProfile(), State: session.GetState(), diff --git a/internal/session/session.go b/internal/session/session.go index 9759d239..b62b4949 100644 --- a/internal/session/session.go +++ b/internal/session/session.go @@ -56,9 +56,7 @@ func (session *SessionCtx) CanAccessClipboard() bool { } func (session *SessionCtx) GetProfile() types.MemberProfile { - profile := session.profile - profile.Secret = "" - return profile + return session.profile } func (session *SessionCtx) profileChanged() { diff --git a/internal/types/session.go b/internal/types/session.go index c1888cbc..f6b669af 100644 --- a/internal/types/session.go +++ b/internal/types/session.go @@ -3,7 +3,6 @@ package types import "net/http" type MemberProfile struct { - Secret string `json:"secret,omitempty"` Name string `json:"name"` IsAdmin bool `json:"is_admin"` CanLogin bool `json:"can_login"`