fix: Update js-sdk with token (#10211)
This commit is contained in:
@@ -58,11 +58,12 @@ export const useLogout = (options?: UseMutationOptions<void, FetchError>) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const useUpdateProviderForEmailPass = (
|
export const useUpdateProviderForEmailPass = (
|
||||||
|
token: string,
|
||||||
options?: UseMutationOptions<void, FetchError, { password: string }>
|
options?: UseMutationOptions<void, FetchError, { password: string }>
|
||||||
) => {
|
) => {
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: (payload) =>
|
mutationFn: (payload) =>
|
||||||
sdk.auth.updateProvider("user", "emailpass", payload),
|
sdk.auth.updateProvider("user", "emailpass", payload, token),
|
||||||
onSuccess: async (data, variables, context) => {
|
onSuccess: async (data, variables, context) => {
|
||||||
options?.onSuccess?.(data, variables, context)
|
options?.onSuccess?.(data, variables, context)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ const ChooseNewPassword = ({ token }: { token: string }) => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const { mutateAsync, isPending } = useUpdateProviderForEmailPass()
|
const { mutateAsync, isPending } = useUpdateProviderForEmailPass(token)
|
||||||
|
|
||||||
const handleSubmit = form.handleSubmit(async ({ password }) => {
|
const handleSubmit = form.handleSubmit(async ({ password }) => {
|
||||||
if (!invite) {
|
if (!invite) {
|
||||||
@@ -123,7 +123,6 @@ const ChooseNewPassword = ({ token }: { token: string }) => {
|
|||||||
|
|
||||||
await mutateAsync(
|
await mutateAsync(
|
||||||
{
|
{
|
||||||
email: invite.entity_id,
|
|
||||||
password,
|
password,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -246,16 +246,16 @@ export class Auth {
|
|||||||
* @param actor - The actor type. For example, `user` for admin user, or `customer` for customer.
|
* @param actor - The actor type. For example, `user` for admin user, or `customer` for customer.
|
||||||
* @param provider - The authentication provider to use. For example, `emailpass`.
|
* @param provider - The authentication provider to use. For example, `emailpass`.
|
||||||
* @param body - The data necessary to update the user's authentication data. When resetting the user's password,
|
* @param body - The data necessary to update the user's authentication data. When resetting the user's password,
|
||||||
* send the `email` and `password` properties.
|
* send the `password` property.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* sdk.auth.updateProvider(
|
* sdk.auth.updateProvider(
|
||||||
* "customer",
|
* "customer",
|
||||||
* "emailpass",
|
* "emailpass",
|
||||||
* {
|
* {
|
||||||
* email: "customer@gmail.com",
|
|
||||||
* password: "supersecret"
|
* password: "supersecret"
|
||||||
* }
|
* },
|
||||||
|
* token
|
||||||
* )
|
* )
|
||||||
* .then(() => {
|
* .then(() => {
|
||||||
* // password updated
|
* // password updated
|
||||||
@@ -264,12 +264,16 @@ export class Auth {
|
|||||||
updateProvider = async (
|
updateProvider = async (
|
||||||
actor: string,
|
actor: string,
|
||||||
provider: string,
|
provider: string,
|
||||||
body: Record<string, unknown>
|
body: Record<string, unknown>,
|
||||||
|
token: string
|
||||||
) => {
|
) => {
|
||||||
await this.client.fetch(`/auth/${actor}/${provider}/update`, {
|
await this.client.fetch(
|
||||||
method: "POST",
|
`/auth/${actor}/${provider}/update?token=${token}`,
|
||||||
body,
|
{
|
||||||
})
|
method: "POST",
|
||||||
|
body,
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user