Coder Social home page Coder Social logo

Comments (8)

ebuzzz avatar ebuzzz commented on September 7, 2024 3

I'm back to using this library, and the current documentation mismatches the code. The README shows that you should create an authorize action in the SiteController. But the Module.php no longer contains the handleAuthorizeRequest method. It was removed in the commit mentioned above.

I believe the method should be added back, or the README should be changed to contain the correct code (by implementing the code that was previously in the Module.php)

    /**
     * @return mixed
     */
    public function actionAuthorize()
    {
        if (Yii::$app->getUser()->getIsGuest())
            return $this->redirect('login');

        /** @var $module \filsh\yii2\oauth2server\Module */
        $module = Yii::$app->getModule('oauth2');
        $response = $module->handleAuthorizeRequest(!Yii::$app->getUser()->getIsGuest(), Yii::$app->getUser()->getId());

        /** @var object $response \OAuth2\Response */
        Yii::$app->getResponse()->format = \yii\web\Response::FORMAT_JSON;

        return $response->getParameters();
    }

from yii2-oauth2-server.

mtangoo avatar mtangoo commented on September 7, 2024

Did something stop working?

from yii2-oauth2-server.

ebuzzz avatar ebuzzz commented on September 7, 2024

I don't know, because I didn't use the method yet :) But commit d8c3aba removed the handleAuthorizeRequest method, and I can't see a reason why:

from yii2-oauth2-server.

mtangoo avatar mtangoo commented on September 7, 2024

can you please test and see if it works as its supposed to?

from yii2-oauth2-server.

ebuzzz avatar ebuzzz commented on September 7, 2024

It's just something I noticed when reading the documentation. I switched to a different module, so I won't be using this code in production.

from yii2-oauth2-server.

SmirnovMaxim avatar SmirnovMaxim commented on September 7, 2024

I'm back to using this library, and the current documentation mismatches the code. The README shows that you should create an authorize action in the SiteController. But the Module.php no longer contains the handleAuthorizeRequest method. It was removed in the commit mentioned above.

I believe the method should be added back, or the README should be changed to contain the correct code (by implementing the code that was previously in the Module.php)

You must change this code to the code below

public function actionAuthorize()
{
        if (Yii::$app->getUser()->getIsGuest())
            return $this->redirect('login');

        /** @var $server filsh\yii2\oauth2server\Server */
        $server = Yii::$app->getModule('oauth2')->getServer();
        $response = $server->handleAuthorizeRequest(null, null, true, Yii::$app->getUser()->getId());

        /** @var object $response \OAuth2\Response */
        Yii::$app->getResponse()->format = \yii\web\Response::FORMAT_JSON;

        return $response->getParameters();
}

from yii2-oauth2-server.

varp avatar varp commented on September 7, 2024

@eborned Could you check if the problem still exist in the latest release v2.1.0?

from yii2-oauth2-server.

varp avatar varp commented on September 7, 2024

Feel free to re-open. Closing due to inactivity.

from yii2-oauth2-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.