Revert 'autogenerate token.'

This commit is contained in:
Miroslav Šedivý 2021-03-13 22:54:34 +01:00
parent 3fcca6ab52
commit cacdd9e20a
4 changed files with 5 additions and 13 deletions

View File

@ -65,10 +65,7 @@ func (h *MembersHandler) membersCreate(w http.ResponseWriter, r *http.Request) {
} }
} }
// TODO: Refactor. session, _, err := h.sessions.Create(data.ID, *data.MemberProfile)
// data.ID
session, _, err := h.sessions.Create(*data.MemberProfile)
if err != nil { if err != nil {
utils.HttpInternalServerError(w, err) utils.HttpInternalServerError(w, err)
return return

View File

@ -31,7 +31,7 @@ func (api *ApiManagerCtx) Login(w http.ResponseWriter, r *http.Request) {
} }
// TODO: Proper login. // TODO: Proper login.
session, token, err := api.sessions.Create(types.MemberProfile{ session, token, err := api.sessions.Create(data.ID, types.MemberProfile{
Name: data.ID, Name: data.ID,
IsAdmin: true, IsAdmin: true,
CanLogin: true, CanLogin: true,

View File

@ -37,12 +37,7 @@ type SessionManagerCtx struct {
emmiter events.EventEmmiter emmiter events.EventEmmiter
} }
func (manager *SessionManagerCtx) Create(profile types.MemberProfile) (types.Session, string, error) { func (manager *SessionManagerCtx) Create(id string, profile types.MemberProfile) (types.Session, string, error) {
id, err := utils.NewUID(32)
if err != nil {
return nil, "", err
}
token, err := utils.NewUID(64) token, err := utils.NewUID(64)
if err != nil { if err != nil {
return nil, "", err return nil, "", err

View File

@ -59,11 +59,11 @@ type Session interface {
} }
type SessionManager interface { type SessionManager interface {
Create(profile MemberProfile) (Session, string, error) Create(id string, profile MemberProfile) (Session, string, error)
Update(id string, profile MemberProfile) error Update(id string, profile MemberProfile) error
Delete(id string) error Delete(id string) error
Get(id string) (Session, bool) Get(id string) (Session, bool)
GetByToken(token string) (Session, bool) GetByToken(token string) (Session, bool)
List() []Session List() []Session
SetHost(host Session) SetHost(host Session)