fix: require login for crypto favorites
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user