fix: update_env resolver

This commit is contained in:
Lakhan Samani
2022-07-01 22:02:34 +05:30
parent 2a5d5d43b0
commit ae34fc7c2b
5 changed files with 109 additions and 15 deletions

View File

@@ -35,10 +35,7 @@ func (c *provider) DeleteAllUserSessions(userId string) error {
constants.AuthRecipeMethodGoogle,
constants.AuthRecipeMethodLinkedIn,
}
if os.Getenv("ENV") != constants.TestEnv {
c.mutex.Lock()
defer c.mutex.Unlock()
}
for _, namespace := range namespaces {
c.sessionStore.RemoveAll(namespace + ":" + userId)
}
@@ -47,14 +44,16 @@ func (c *provider) DeleteAllUserSessions(userId string) error {
// DeleteUserSession deletes the user session from the in-memory store.
func (c *provider) DeleteUserSession(userId, sessionToken string) error {
if os.Getenv("ENV") != constants.TestEnv {
c.mutex.Lock()
defer c.mutex.Unlock()
}
c.sessionStore.Remove(userId, sessionToken)
return nil
}
// DeleteSessionForNamespace to delete session for a given namespace example google,github
func (c *provider) DeleteSessionForNamespace(namespace string) error {
c.sessionStore.RemoveByNamespace(namespace)
return nil
}
// SetState sets the state in the in-memory store.
func (c *provider) SetState(key, state string) error {
if os.Getenv("ENV") != constants.TestEnv {

View File

@@ -2,6 +2,7 @@ package stores
import (
"os"
"strings"
"sync"
"github.com/authorizerdev/authorizer/server/constants"
@@ -65,3 +66,18 @@ func (s *SessionStore) GetAll(key string) map[string]string {
}
return s.store[key]
}
// RemoveByNamespace to delete session for a given namespace example google,github
func (s *SessionStore) RemoveByNamespace(namespace string) error {
if os.Getenv("ENV") != constants.TestEnv {
s.mutex.Lock()
defer s.mutex.Unlock()
}
for key := range s.store {
if strings.Contains(key, namespace+":") {
delete(s.store, key)
}
}
return nil
}