Chatter-Laravel / core

The Laravel single page forum package (Vue + Tailwind CSS + Laravel)
MIT License
159 stars 39 forks source link

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

Open mshahinaz29 opened 3 years ago

mshahinaz29 commented 3 years ago

Screenshot_531

petertsoisstuff commented 3 years ago

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),
KnowledgeWanderer commented 3 years ago

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 commented 3 years ago

@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.

sbarbat commented 3 years ago

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

KnowledgeWanderer commented 3 years ago

@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.

ericleversen commented 2 years ago

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 commented 2 years ago

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…]()