Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid/Not existed username handle in API ShowUserController #1846

Closed
ganuonglachanh opened this issue Aug 12, 2019 · 0 comments · Fixed by #1901
Closed

Invalid/Not existed username handle in API ShowUserController #1846

ganuonglachanh opened this issue Aug 12, 2019 · 0 comments · Fixed by #1901

Comments

@ganuonglachanh
Copy link

Bug Report

Current Behavior
spinning icon with error popup when go to url with invalid/not existed usename

Steps to Reproduce

  1. Go to https://discuss.flarum.org/u/notexisteduser
  2. See error

Expected Behavior
A user not found handler, not a spinning icon with error popup

Environment

  • Flarum version: beta 0.9

Possible Solution

    protected function data(ServerRequestInterface $request, Document $document)
    {
        $id = Arr::get($request->getQueryParams(), 'id');
        if (! is_numeric($id)) {
            $id = $this->users->getIdForUsername($id);
        }
        $actor = $request->getAttribute('actor');
        if ($actor->id == $id) { 
//should be === when $actor->id = 0 and $id = null
            $this->serializer = CurrentUserSerializer::class;
        }
        return $this->users->findOrFail($id, $actor);
 //-> need better handler when actor is guest and $id = null, save some DB queries
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants