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

Nicer message for Error 400 after inactivity #7

Open
fjf2002 opened this issue Aug 16, 2023 · 5 comments
Open

Nicer message for Error 400 after inactivity #7

fjf2002 opened this issue Aug 16, 2023 · 5 comments

Comments

@fjf2002
Copy link
Contributor

fjf2002 commented Aug 16, 2023

In loose conjunction with #5,

when users click around in a 15 mins old dokuwiki webpage, they get a

OAuth: An error occured during the request to the oauth provider: [HTTP 400]

in their face. It simply should read, "You have been logged out. Please re-login."

Inside Keycloak.php, you could override the method refreshAccessToken with:

public function refreshAccessToken(TokenInterface $token) {
    try {
        return parent::refreshAccessToken($token);
    } catch (TokenResponseException $exc) {
        if ($exc->getMessage() === "An error occured during the request to the oauth provider:\n [HTTP 400]") {
            throw new TokenResponseException(
                'You have been logged out. Please re-login.',
                $exc->getCode(),
                $exc
        );
        } else {
            throw $exc;
        }
    }
}
@YoitoFes
Copy link
Owner

Thank you for the awesome suggestion. I will try it.

@fjf2002
Copy link
Contributor Author

fjf2002 commented Aug 16, 2023

I forgot to mention the use statements needed:

use OAuth\Common\Http\Exception\TokenResponseException;
use OAuth\Common\Token\TokenInterface;

@fjf2002
Copy link
Contributor Author

fjf2002 commented Apr 18, 2024

Hello @YoitoFes, any advancements on this topic? Thank You.

@ZID-TU-Graz-Collab
Copy link

We are also affected. Any news here @YoitoFes ? Thank you

@YoitoFes
Copy link
Owner

IMO, the suggested approach is dependent on the hard-coded string in dokuwiki\plugin\oauth\HTTPClient, making the maintenance hard.

Since I want to check the field/method which indicates HTTP status code directly, made the feature request (cosmocode/dokuwiki-plugin-oauth/issues/149).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants