f1909da1ad
Go CI / build (push) Failing after 2m42s
feat: create basic server to manage google oauth, account, sessions, places, attributes and ratings.
27 lines
648 B
Go
27 lines
648 B
Go
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()
|
|
}
|