Other(refactor): Less unwieldy user type in Bridge

Instead of the annoying safe.Map type, we just use a normal go map
and mutex pair, and use safe.Lock/safe.RLock as a helper function
This commit is contained in:
James Houlahan
2022-10-26 23:04:25 +02:00
parent 85c0d6f837
commit 2bda47fcad
11 changed files with 458 additions and 227 deletions

View File

@ -402,11 +402,13 @@ func (user *User) OnStatusDown() {
}
// Logout logs the user out from the API.
func (user *User) Logout(ctx context.Context) error {
func (user *User) Logout(ctx context.Context, withAPI bool) error {
user.tasks.Wait()
if err := user.client.AuthDelete(ctx); err != nil {
return fmt.Errorf("failed to delete auth: %w", err)
if withAPI {
if err := user.client.AuthDelete(ctx); err != nil {
return fmt.Errorf("failed to delete auth: %w", err)
}
}
if err := user.vault.Clear(); err != nil {