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

Is Laravel Sanctum as a Provider on the roadmap? #10

Open
Skylercrane23 opened this issue Nov 10, 2023 · 4 comments
Open

Is Laravel Sanctum as a Provider on the roadmap? #10

Skylercrane23 opened this issue Nov 10, 2023 · 4 comments
Labels
question Further information is requested

Comments

@Skylercrane23
Copy link

Was curious if Laravel Sanctum is on the roadmap to becoming a provider. I currently use Nuxt Auth for my Nuxt2 Applications and really enjoyed how simple that was to get Laravel Sanctum working with. Have recently started several new Nuxt3 projects with a Laravel backend.

Any info would be great, Thanks!

@Atinux
Copy link
Owner

Atinux commented Nov 10, 2023

Hey, have you check https://github.com/dystcz/nuxt-sanctum-auth ?

@Skylercrane23
Copy link
Author

I think I saw this one before but doesn't have full SSR support :(

@nhedger
Copy link

nhedger commented Nov 11, 2023

@Skylercrane23, let me shamelessly plug my own module, which handles SSR:

https://github.com/nhedger/nuxt-sanctum

Still ironing things out, and early feedback would be appreciated.

@Atinux Atinux added the question Further information is requested label Nov 20, 2023
@MarJose123
Copy link

I'm using Laravel Sanctum and here what I did to make it work.

I've created a signin.post.ts file in server/api/auth and I used the setUserSession utils.

  await setUserSession(event, {
    user: {
      ...loginResponse?.user
    },
    loggedInAt: new Date()
    // Any extra fields
  })
  return {status: 200, success: true}

and on my login page logic

const login = await $fetch("/api/auth/signin",{
    method: 'POST',
    body: JSON.stringify({
      email: data?.email,
      password: data?.password,
    }),
    headers: {
      'Content-Type': 'application/json',
    }.catch((resp) => console.log(resp))
    
    if(login?.status === 200 && login?.success){
    window.location.href = '/login'
  }

On your page, you can now retrieve the user session using the composable util

const { loggedIn, user, session, clear } = useUserSession()

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

No branches or pull requests

4 participants