Skip to content

Commit b6681f2

Browse files
committed
feat: add new user actions to log
* renew access token * refresh token void Change-Id: Ibe2c590dbdb95146e46f8edca9420101670f1629
1 parent 1b874e5 commit b6681f2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

app/Models/OAuth2/RefreshToken.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
**/
14+
15+
use App\Jobs\AddUserAction;
1416
use Auth\User;
1517
use DateInterval;
1618
use DateTime;
1719
use DateTimeZone;
1820
use App\Models\Utils\BaseEntity;
1921
use Doctrine\Common\Collections\ArrayCollection;
2022
use Doctrine\ORM\Mapping AS ORM;
23+
use Utils\IPHelper;
24+
2125
/**
2226
* @ORM\Entity(repositoryClass="App\Repositories\DoctrineRefreshTokenRepository")
2327
* @ORM\Table(name="oauth2_refresh_token")
@@ -153,6 +157,10 @@ public function setFriendlyScopes($friendly_scopes){
153157
public function setVoid(){
154158
$this->void = true;
155159
$this->updated_at = new \DateTime('now', new \DateTimeZone(self::DefaultTimeZone));
160+
if($this->hasOwner()) {
161+
$action = sprintf("Revoked refresh token id %s client %s.", $this->id, $this->client->getClientId());
162+
AddUserAction::dispatch($this->owner->getId(), IPHelper::getUserIp(), $action);
163+
}
156164
}
157165

158166
/**

app/Services/OAuth2/TokenService.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,8 @@ public function createAccessTokenFromRefreshToken(RefreshToken $refresh_token, $
635635
if (!is_null($user_id)) {
636636
$user = $this->auth_service->getUserById($user_id);
637637
$access_token_db->setOwner($user);
638+
$action = sprintf("Access token renewed from Refresh Token %s Client %s", $refresh_token_db->getId(), $client_id);
639+
AddUserAction::dispatch($user->getId(), IPHelper::getUserIp(), $action);
638640
}
639641

640642
$this->access_token_repository->add($access_token_db);

0 commit comments

Comments
 (0)