Giter Site home page Giter Site logo

Comments (2)

ryzr avatar ryzr commented on August 15, 2024

Hmmm, so I guess this is the only block with the Result object available:

https://github.com/black-bits/laravel-cognito-auth/blob/master/src/Auth/CognitoGuard.php#L42-L63

Possibly a contract and trait could be created - which provides a method to temporarily store the result on the user object. In pseudo-code, something like:

protected function hasValidCredentials($user, $credentials)
{
    ...

    if ($user instanceof CognitoAuthenticable) {
        $user->setCognitoResult($result)
    }
}

And then in your LoginController, usage would look like:

    /**
     * The user has been authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  mixed  $user
     * @return mixed
     */
    protected function authenticated(Request $request, $user)
    {
        $result = $user->getCognitoResult();
        $accessToken = $result ? $result['AccessToken'] : null;
    }

Alternatively, the result could be saved inside the guard? The only iffy thing about this, is IDEs wouldn't really understand auth()->cognitoResult() and Auth::cognitoResult()

What do you think?

note: I'm not a maintainer here - but I'm certainly interested in this package and its future development

from laravel-cognito-auth.

bluehaoran avatar bluehaoran commented on August 15, 2024

Thanks @ryzr ! At first glance, that's definitely much better than my first, second, or third thought. I'll think on it for a little longer, and then I will probably go down your route.

from laravel-cognito-auth.

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.