Пример #1
0
 /**
  * {@inheritdoc}
  */
 protected function delete(Request $request)
 {
     $id = $request->get('id');
     $actor = $request->actor;
     $input = $request->all();
     $this->bus->dispatch(new DeleteDiscussion($id, $actor, $input));
 }
Пример #2
0
 public function handle(Request $request)
 {
     $userChannel = 'private-user' . $request->actor->id;
     if ($request->get('channel_name') === $userChannel) {
         $pusher = new Pusher($this->settings->get('pusher.app_key'), $this->settings->get('pusher.app_secret'), $this->settings->get('pusher.app_id'));
         $payload = json_decode($pusher->socket_auth($userChannel, $request->get('socket_id')), true);
         return new JsonResponse($payload);
     }
     return new EmptyResponse(403);
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function handle(Request $request, array $routeParams = [])
 {
     if (!$request->actor->isAdmin()) {
         throw new PermissionDeniedException();
     }
     $permission = $request->get('permission');
     $groupIds = $request->get('groupIds');
     Permission::where('permission', $permission)->delete();
     Permission::insert(array_map(function ($groupId) use($permission) {
         return ['permission' => $permission, 'group_id' => $groupId];
     }, $groupIds));
     return new EmptyResponse(204);
 }
Пример #4
0
 protected function delete(Request $request)
 {
     if (!$request->actor->isAdmin()) {
         throw new PermissionDeniedException();
     }
     $name = $request->get('name');
     $this->extensions->disable($name);
     $this->extensions->uninstall($name);
     app('flarum.formatter')->flush();
     $forum = app('Flarum\\Forum\\Actions\\ClientAction');
     $forum->flushAssets();
     $admin = app('Flarum\\Admin\\Actions\\ClientAction');
     $admin->flushAssets();
 }
Пример #5
0
 /**
  * Log in and return a token.
  *
  * @param Request $request
  * @return \Psr\Http\Message\ResponseInterface
  * @throws PermissionDeniedException
  */
 public function handle(Request $request)
 {
     $identification = $request->get('identification');
     $password = $request->get('password');
     $user = $this->users->findByIdentification($identification);
     if (!$user || !$user->checkPassword($password)) {
         throw new PermissionDeniedException();
     }
     if (!$user->is_activated) {
         event(new UserEmailChangeWasRequested($user, $user->email));
         return new JsonResponse(['code' => 'confirm_email', 'email' => $user->email], 401);
     }
     $token = $this->bus->dispatch(new GenerateAccessToken($user->id));
     return new JsonResponse(['token' => $token->id, 'userId' => $user->id]);
 }
Пример #6
0
 public function handle(Request $request)
 {
     if (!$request->actor->isAdmin()) {
         throw new PermissionDeniedException();
     }
     $order = $request->get('order');
     Tag::query()->update(['position' => null, 'parent_id' => null]);
     foreach ($order as $i => $parent) {
         $parentId = array_get($parent, 'id');
         Tag::where('id', $parentId)->update(['position' => $i]);
         if (isset($parent['children']) && is_array($parent['children'])) {
             foreach ($parent['children'] as $j => $childId) {
                 Tag::where('id', $childId)->update(['position' => $j, 'parent_id' => $parentId]);
             }
         }
     }
     return new EmptyResponse(204);
 }
Пример #7
0
 public function handle(Request $request)
 {
     if (!$request->actor->isAdmin()) {
         throw new PermissionDeniedException();
     }
     $enabled = $request->get('enabled');
     $name = $request->get('name');
     if ($enabled === true) {
         $this->extensions->enable($name);
     } elseif ($enabled === false) {
         $this->extensions->disable($name);
     }
     app('flarum.formatter')->flush();
     $forum = app('Flarum\\Forum\\Actions\\ClientAction');
     $forum->flushAssets();
     $admin = app('Flarum\\Admin\\Actions\\ClientAction');
     $admin->flushAssets();
 }
Пример #8
0
 /**
  * {@inheritdoc}
  */
 public function handle(Request $request, array $routeParams = [])
 {
     if (!$request->actor->isAdmin()) {
         throw new PermissionDeniedException();
     }
     $config = $request->get('config', []);
     // TODO: throw HTTP status 400 or 422
     if (!is_array($config)) {
         throw new Exception();
     }
     foreach ($config as $k => $v) {
         $this->settings->set($k, $v);
         if (strpos($k, 'theme_') === 0 || $k === 'custom_less') {
             $forum = app('Flarum\\Forum\\Actions\\ClientAction');
             $forum->flushAssets();
             $admin = app('Flarum\\Admin\\Actions\\ClientAction');
             $admin->flushAssets();
         }
     }
     return new EmptyResponse(204);
 }
Пример #9
0
 /**
  * Log in and return a token.
  *
  * @param \Flarum\Api\Request $request
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function handle(Request $request)
 {
     $email = $request->get('email');
     $this->bus->dispatch(new RequestPasswordReset($email));
     return new EmptyResponse();
 }
Пример #10
0
 /**
  * Delete a discussion.
  *
  * @param \Flarum\Api\Request $request
  * @param \Illuminate\Http\Response $response
  * @return void
  */
 protected function delete(Request $request, Response $response)
 {
     $this->bus->dispatch(new DeleteDiscussionCommand($request->get('id'), $request->actor->getUser()));
 }
Пример #11
0
 /**
  * Delete a tag.
  *
  * @param Request $request
  */
 protected function delete(Request $request)
 {
     $this->bus->dispatch(new DeleteTag($request->get('id'), $request->actor));
 }
Пример #12
0
 /**
  * Delete reports for a post.
  *
  * @param Request $request
  */
 protected function delete(Request $request)
 {
     $this->bus->dispatch(new DeleteReports($request->get('id'), $request->actor, $request->all()));
 }
Пример #13
0
 /**
  * Log in and return a token.
  *
  * @param \Flarum\Api\Request $request
  * @return \Flarum\Api\Response
  */
 public function respond(Request $request)
 {
     $email = $request->get('email');
     $this->bus->dispatch(new RequestPasswordResetCommand($email));
     return new Response();
 }