fix: require login for crypto favorites

This commit is contained in:
hajimi
2026-08-02 02:37:31 +08:00
parent cd054d4db6
commit 1c6ebf3e3c
2 changed files with 20 additions and 0 deletions
@@ -29,6 +29,9 @@ class CryptoController extends BaseApiController
*/
public function favorites()
{
if ($this->userId <= 0) {
return $this->fail('请先登录', [], 401);
}
return $this->data(['symbols' => CryptoLogic::favorites($this->userId)]);
}
@@ -37,6 +40,9 @@ class CryptoController extends BaseApiController
*/
public function addFavorite()
{
if ($this->userId <= 0) {
return $this->fail('请先登录', [], 401);
}
$params = (new CryptoValidate())->post()->goCheck('favorite');
if (!CryptoLogic::addFavorite($this->userId, (string) $params['symbol'])) {
return $this->fail(CryptoLogic::getError());
@@ -49,6 +55,9 @@ class CryptoController extends BaseApiController
*/
public function cancelFavorite()
{
if ($this->userId <= 0) {
return $this->fail('请先登录', [], 401);
}
$params = (new CryptoValidate())->post()->goCheck('favorite');
if (!CryptoLogic::cancelFavorite($this->userId, (string) $params['symbol'])) {
return $this->fail(CryptoLogic::getError());