core icon indicating copy to clipboard operation
core copied to clipboard

401 (Unauthorized) : Can't submit a message, react to a post or save a username.

Open mshahinaz29 opened this issue 4 years ago • 7 comments

Screenshot_531

mshahinaz29 avatar Feb 10 '21 03:02 mshahinaz29

Looks like this is a bug of laravel/passport:^8 https://github.com/laravel/passport/blob/6affa6ed600c5f8909385fbae7cf6f8af3db2d39/src/Guards/TokenGuard.php#L251

protected function decodeJwtTokenCookie($request)
{
    return (array) JWT::decode(
        $this->encrypter->decrypt($request->cookie(Passport::cookie()), Passport::$unserializesCookies),
        $this->encrypter->getKey(),
        ['HS256']
    );
}

Upgrade to laravel/passport:^9 will fix it

Quick Fix: Replace

$this->encrypter->decrypt($request->cookie(Passport::cookie()), Passport::$unserializesCookies),

with

substr($this->encrypter->decrypt($request->cookie(Passport::cookie()), Passport::$unserializesCookies), 41),

petertsoisstuff avatar May 27 '21 10:05 petertsoisstuff

Quick Fix: Replace

$this->encrypter->decrypt($request->cookie(Passport::cookie()), Passport::$unserializesCookies),

with

substr($this->encrypter->decrypt($request->cookie(Passport::cookie()), Passport::$unserializesCookies), 41),

Having the same issue and this doesn't fix my problem sadly.

Any ideas what could be done?

KnowledgeWanderer avatar Jul 29 '21 19:07 KnowledgeWanderer

@sbarbat I tried for a few hours now and can't figure out what's wrong. Can you please provide some assistance? I really need this package to work, as it's amazing and exactly what I need for my project.

Thank you and sorry for tagging you.

KnowledgeWanderer avatar Jul 29 '21 20:07 KnowledgeWanderer

Sorry thaat havent got any time to look into this, will do it this weekend! 💪 @KnowledgeWanderer

sbarbat avatar Jul 30 '21 14:07 sbarbat

@sbarbat no need to be sorry, you did something great here, that's free and open source. If what I want to make will work, I'll support this project and pump some money into it. Thinking of actually donating towards it nevertheless, but it has to work well first of all.

KnowledgeWanderer avatar Jul 30 '21 14:07 KnowledgeWanderer

I have the same issue @sbarbat

composer.lock Laravel 8.7 Passsport 10.2 chatter-laravel/core dev-master c3a447f

When I click the Ask a Question button I get a console error shown in attached screen shot. The first error, api/chatter/discussion 401, happens on the click.

The second error, Error: Request failed with status code 401...app.js:2539:17, occurs on loading the new page which is the default home page /home

I'm planning (hoping) to use this in production and will happily contribute $$$ to its upkeep.

Screen Shot 2021-12-04 at 6 49 23 PM

ericleversen avatar Dec 05 '21 00:12 ericleversen

As a follow up, if I hit the page directly it returns a properly formatted json file with chatter data. See attached @sbarbat Uploading Screen Shot 2021-12-07 at 7.08.37 PM.png…

ericleversen avatar Dec 08 '21 01:12 ericleversen