diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-01-08 00:51:37 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-01-08 00:51:37 (GMT) |
commit | 2e548139a6806bab10d1b184e0120dbcb1f99c1f (patch) | |
tree | f939f43d2e635e4e946b4f0b6ae38aaed277cab0 /session_store.go | |
parent | 6741874cf6746eecdef94da3bc34e73ac139d363 (diff) |
move rddb to rhrd-go
Diffstat (limited to 'session_store.go')
-rw-r--r-- | session_store.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/session_store.go b/session_store.go index 8b48c0a..e47366e 100644 --- a/session_store.go +++ b/session_store.go @@ -28,6 +28,7 @@ import ( "crypto/rand" "encoding/base64" "fmt" + "helsinki.at/rhrd-go/rddb" "net/http" ) @@ -90,7 +91,7 @@ type SessionStoreElement struct { type SessionStore struct { store map[string]map[string]*SessionStoreElement conf *Config - rddb *RdDbChan + db *rddb.DBChan quit chan bool done chan bool newChan chan newSessionRequest @@ -111,7 +112,7 @@ func (self *SessionStore) new(ctx *Context, refId string) (resp newSessionRespon resp.responsecode = http.StatusOK resp.errorstring = "OK" if !ctx.Trusted { - if ok, err := self.rddb.CheckPassword(ctx.UserName, ctx.Password); err != nil { + if ok, err := self.db.CheckPassword(ctx.UserName, ctx.Password); err != nil { resp.responsecode = http.StatusInternalServerError resp.errorstring = err.Error() return @@ -130,7 +131,7 @@ func (self *SessionStore) new(ctx *Context, refId string) (resp newSessionRespon self.store[ctx.UserName] = make(map[string]*SessionStoreElement) } ctx.conf = self.conf - ctx.rddb = self.rddb + ctx.db = self.db s := &SessionStoreElement{newSession(ctx, func() { self.GetInterface().Remove(ctx.UserName, resp.id) }), refId} self.store[ctx.UserName][resp.id] = s resp.session = self.store[ctx.UserName][resp.id].s.getInterface() @@ -156,7 +157,7 @@ func (self *SessionStore) list(user, password string, trusted bool) (resp listSe resp.responsecode = http.StatusOK resp.errorstring = "OK" if !trusted { - if ok, err := self.rddb.CheckPassword(user, password); err != nil { + if ok, err := self.db.CheckPassword(user, password); err != nil { resp.responsecode = http.StatusInternalServerError resp.errorstring = err.Error() return @@ -292,10 +293,10 @@ func (self *SessionStore) Cleanup() { close(self.removeChan) } -func NewSessionStore(conf *Config, rddb *RdDbChan) (store *SessionStore, err error) { +func NewSessionStore(conf *Config, db *rddb.DBChan) (store *SessionStore, err error) { store = new(SessionStore) store.conf = conf - store.rddb = rddb + store.db = db store.quit = make(chan bool) store.done = make(chan bool) store.store = make(map[string]map[string]*SessionStoreElement) |