Skip to content

Commit

Permalink
https://github.com/humhub/fcm-push/pull/63#discussion_r1904417431
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-farre committed Jan 6, 2025
1 parent 141c19f commit 7356b59
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions controllers/TokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ public function beforeAction($action)

public function actionUpdate()
{
return $this->update(false);
return $this->update(false, Yii::$app->request->post('token'));
}

public function actionUpdateMobileApp()
{
return $this->update(true);
return $this->update(true, Yii::$app->request->post('token'));
}

public function actionDelete()
{
return $this->delete(false);
return $this->delete(false, Yii::$app->request->post('token'));
}

public function actionDeleteMobileApp()
{
return $this->delete(true);
return $this->delete(true, Yii::$app->request->post('token'));
}

private function update(bool $mobile)
private function update(bool $mobile, ?string $token)
{
if (Yii::$app->user->isGuest) {
throw new HttpException(401, 'Login required!');
Expand All @@ -69,12 +69,12 @@ private function update(bool $mobile)
'success' => $tokenService->storeTokenForUser(
Yii::$app->user->getIdentity(),
$driver,
Yii::$app->request->post('token'),
$token,
),
]);
}

private function delete(bool $mobile)
private function delete(bool $mobile, ?string $token)
{
$driverService = new DriverService($this->module->getConfigureForm());
$tokenService = new TokenService();
Expand All @@ -92,9 +92,7 @@ private function delete(bool $mobile)
}

return $this->asJson([
'success' => $tokenService->deleteToken(
Yii::$app->request->post('token'),
),
'success' => $tokenService->deleteToken($token),
]);
}
}

0 comments on commit 7356b59

Please sign in to comment.