private function authorize($publicKey, $privateKey) { $exists = Model::ApiUser()->where(['public_key', '=', (string) $publicKey])->where(['private_key', '=', (string) $privateKey])->first(true); if ($exists) { $token = Utils::token(); $row = Model::ApiAuth()->firstOrCreate(['user_id' => (int) $exists->id]); $row->setToken($token)->setExpiration(time() + 3600)->save(); Api::render(['status' => 200, 'execution_time' => Timer::get(), 'token' => $token]); } Api::forbidden(); }