diff --git a/src/TokenConfigStorage.php b/src/TokenConfigStorage.php index 2d22292..901c6d0 100644 --- a/src/TokenConfigStorage.php +++ b/src/TokenConfigStorage.php @@ -30,17 +30,17 @@ public function save($token) { $gmailConfig = $this->configRepo->get('gmail'); $dataProvider = $this->configRepo->get('data-provider'); - + $credentials = $dataProvider->asArray()['gmail']; $credentials['email'] = $token['email']; $credentials['authenticated'] = empty($token) ? false : true; - + $gmailConfig->setState([ "token_for_{$token['email']}" => $token, ]); $dataProvider->setState([ - 'gmail' => $credentials + 'gmail' => $credentials ]); $this->configRepo->update($gmailConfig); @@ -49,6 +49,19 @@ public function save($token) public function delete($email) { - $this->save(['email' => $email]); + $gmailConfig = $this->configRepo->get('gmail'); + $dataProvider = $this->configRepo->get('data-provider'); + $credentials = $dataProvider->asArray()['gmail']; + + $dataProvider->setState([ + 'gmail' => $credentials + [ 'email' => '', 'authenticated' => false ] + ]); + + $gmailConfig->setState([ + "token_for_{$email}" => '', + ]); + + $this->configRepo->update($gmailConfig); + $this->configRepo->update($dataProvider); } }