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

Support Dot Notation for keyUser in fetchUser Method #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/options/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ Default oauth2 request data.

Default fetch request data.

> The `keyUser` option now supports dot notation, allowing you to specify nested keys within the user object. For example, if your user object is structured as `{ profile: { details: { name: 'John' } } }`, you can use `keyUser: 'profile.details.name'` to access the name.

#### References

- [Requests Guide](/guide/requests)
Expand Down Expand Up @@ -512,4 +514,4 @@ Default unimpersonate request data.
- [unimpersonate() Method](/methods/impersonating#unimpersonate)
- [redirect Option](/options/options-generate#redirect)
- [fetchUser Option](/options/options-generate#fetchuser)
- [makeRequest Option](/options/options-generate#makerequest)
- [makeRequest Option](/options/options-generate#makerequest)
8 changes: 4 additions & 4 deletions src/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ export default class Auth {
const keyUser = fetchData.keyUser
setUserData(
this,
keyUser ? response.data[keyUser] : response.data,
keyUser ? getProperty(response.data, keyUser) : response.data,
data?.redirect
)

Expand Down Expand Up @@ -614,7 +614,7 @@ export default class Auth {
: this.options.fetchData.keyUser
setUserData(
this,
keyUser ? response.data[keyUser] : response.data,
keyUser ? getProperty(response.data, keyUser) : response.data,
registerData.redirect
)

Expand Down Expand Up @@ -646,7 +646,7 @@ export default class Auth {
: this.options.fetchData.keyUser
setUserData(
this,
keyUser ? response.data[keyUser] : response.data,
keyUser ? getProperty(response.data, keyUser) : response.data,
loginData.redirect
)
}
Expand Down Expand Up @@ -807,4 +807,4 @@ export default class Auth {
this.currentToken = this.options.tokenDefaultKey
}
}
}
}
Loading