feat: create basic server to manage google oauth, account, sessions, places, attributes and ratings.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package store
|
||||
|
||||
import "git.pengzhan.dev/noteplace-server/internal/models"
|
||||
|
||||
func (s *Store) CreateSession(session models.Session) error {
|
||||
s.Mu.Lock()
|
||||
defer s.Mu.Unlock()
|
||||
s.Data.Sessions[session.ID] = session
|
||||
return s.save()
|
||||
}
|
||||
|
||||
// GetSessionByUserID finds a session by its ID.
|
||||
func (s *Store) GetSessionBySessionID(sessionID string) (models.Session, bool) {
|
||||
s.Mu.RLock()
|
||||
defer s.Mu.RUnlock()
|
||||
se, ok := s.Data.Sessions[sessionID]
|
||||
return se, ok
|
||||
}
|
||||
|
||||
// DeleteSession removes a session from the store.
|
||||
func (s *Store) DeleteSession(sessionID string) error {
|
||||
s.Mu.Lock()
|
||||
defer s.Mu.Unlock()
|
||||
delete(s.Data.Sessions, sessionID)
|
||||
return s.save()
|
||||
}
|
||||
Reference in New Issue
Block a user