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

get local provider reponse data #583

Closed
prabodhana opened this issue Nov 23, 2023 · 9 comments
Closed

get local provider reponse data #583

prabodhana opened this issue Nov 23, 2023 · 9 comments

Comments

@prabodhana
Copy link

How can I get the response data on local provide sign in method. I tried it like this

const {data} = await signIn({})

But it return undefined value

@karis
Copy link

karis commented Nov 23, 2023

hi @prabodhana

on your Login.vue, you need to setup login
`
const { signIn, getProviders } = useAuth()

const result = ref()
result.value = await signIn('credentials', {
username: values.username,
password: values.password,
redirect: false,
callbackUrl: '/clinic'
})
`
if you want to retrieve signed in data

in other your protected page
example dashboard.vue :
`

const { data } = useAuth()

console.log(JSON.stringify(data))
`

@prabodhana
Copy link
Author

hello @karis

const { data } = useAuth() provide the session data. Its working without an issue. I need to get my login response data. not the session response data.

@karis
Copy link

karis commented Nov 23, 2023

hi @prabodhana

on your Login.vue, you need to setup login ` const { signIn, getProviders } = useAuth()

const result = ref() result.value = await signIn('credentials', { username: values.username, password: values.password, redirect: false, callbackUrl: '/clinic' }) ` if you want to retrieve signed in data

in other your protected page example dashboard.vue : `

const { data } = useAuth()

console.log(JSON.stringify(data)) `

sure, have you try this?

const result = ref() 
result.value = await signIn('credentials', { 
username: values.username, 
password: values.password, 
redirect: false, callbackUrl: '/clinic' }) 

 console.log(JSON.stringify(data)) 

@prabodhana
Copy link
Author

prabodhana commented Nov 23, 2023

@karis

Yes. it return undefined

@karis
Copy link

karis commented Nov 23, 2023

@prabodhana

can you build your reproduction? stackblitz
or may be you can share your

  • nuxt.config.ts
  • login.vue
  • api/auth/[...].ts

@prabodhana
Copy link
Author

@prabodhana

can you build your reproduction? stackblitz or may be you can share your

* nuxt.config.ts

* login.vue

* api/auth/[...].ts

Ok. I'm not use authjs provider. I'm used new 0.6 local-auth-provider

@muhammadfakhriabdullah
Copy link

check this in your nuxt.config.ts
signInResponseTokenPointer: ''
this will point to your token from BE response
in my case, I got this response from BackEnd
{ "code": 200, "message": "Success", "data": { "token": "eyBlablabla", "expired": "2023-12-06T05:51:30.936795Z" } }

so I set signInResponseTokenPointer to
signInResponseTokenPointer: '/data/token'

@prabodhana
Copy link
Author

prabodhana commented Dec 6, 2023

check this in your nuxt.config.ts signInResponseTokenPointer: '' this will point to your token from BE response in my case, I got this response from BackEnd { "code": 200, "message": "Success", "data": { "token": "eyBlablabla", "expired": "2023-12-06T05:51:30.936795Z" } }

so I set signInResponseTokenPointer to signInResponseTokenPointer: '/data/token'

Yes. But I need get some extra data from the response like this

{ "code": 200, "message": "Success", "data": { "token": "eyBlablabla", "expired": "2023-12-06T05:51:30.936795Z" , "extra_data" : '######'} }

@valh1996
Copy link
Contributor

valh1996 commented Dec 7, 2023

Hey @prabodhana,
As you can see in the code, the http response is not returned so it's not possible.

Feel free to send a PR if you want! In this case, remember to update the refresh provider as well.

@sidebase sidebase locked and limited conversation to collaborators Feb 23, 2024
@zoey-kaiser zoey-kaiser converted this issue into discussion #681 Feb 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants