2020-07-07 10:14:12 +00:00
|
|
|
import { fragmentUser } from "@saleor/fragments/auth";
|
|
|
|
import { accountErrorFragment } from "@saleor/fragments/errors";
|
2019-06-19 14:40:52 +00:00
|
|
|
import gql from "graphql-tag";
|
|
|
|
|
|
|
|
import { TypedMutation } from "../mutations";
|
2019-09-02 19:23:37 +00:00
|
|
|
import {
|
|
|
|
RequestPasswordReset,
|
|
|
|
RequestPasswordResetVariables
|
|
|
|
} from "./types/RequestPasswordReset";
|
2019-09-03 13:42:15 +00:00
|
|
|
import { SetPassword, SetPasswordVariables } from "./types/SetPassword";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
export const tokenAuthMutation = gql`
|
|
|
|
${fragmentUser}
|
|
|
|
mutation TokenAuth($email: String!, $password: String!) {
|
|
|
|
tokenCreate(email: $email, password: $password) {
|
2020-07-13 14:53:48 +00:00
|
|
|
errors: accountErrors {
|
2019-06-19 14:40:52 +00:00
|
|
|
field
|
|
|
|
message
|
|
|
|
}
|
2020-07-23 13:37:39 +00:00
|
|
|
csrfToken
|
|
|
|
token
|
2019-06-19 14:40:52 +00:00
|
|
|
user {
|
|
|
|
...User
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const tokenVerifyMutation = gql`
|
|
|
|
${fragmentUser}
|
|
|
|
mutation VerifyToken($token: String!) {
|
|
|
|
tokenVerify(token: $token) {
|
|
|
|
payload
|
|
|
|
user {
|
|
|
|
...User
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2019-09-02 19:23:37 +00:00
|
|
|
|
2020-07-14 14:31:41 +00:00
|
|
|
export const tokenRefreshMutation = gql`
|
2020-07-13 14:53:48 +00:00
|
|
|
mutation RefreshToken($token: String!) {
|
|
|
|
tokenRefresh(csrfToken: $token) {
|
|
|
|
token
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2019-09-02 19:23:37 +00:00
|
|
|
export const requestPasswordReset = gql`
|
2020-04-23 15:43:08 +00:00
|
|
|
${accountErrorFragment}
|
2019-09-02 19:23:37 +00:00
|
|
|
mutation RequestPasswordReset($email: String!, $redirectUrl: String!) {
|
|
|
|
requestPasswordReset(email: $email, redirectUrl: $redirectUrl) {
|
2020-03-10 13:33:43 +00:00
|
|
|
errors: accountErrors {
|
|
|
|
...AccountErrorFragment
|
2019-09-02 19:23:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const RequestPasswordResetMutation = TypedMutation<
|
|
|
|
RequestPasswordReset,
|
|
|
|
RequestPasswordResetVariables
|
|
|
|
>(requestPasswordReset);
|
2019-09-03 13:42:15 +00:00
|
|
|
|
|
|
|
export const setPassword = gql`
|
2020-04-23 15:43:08 +00:00
|
|
|
${accountErrorFragment}
|
2019-09-03 13:42:15 +00:00
|
|
|
${fragmentUser}
|
|
|
|
mutation SetPassword($email: String!, $password: String!, $token: String!) {
|
|
|
|
setPassword(email: $email, password: $password, token: $token) {
|
2020-03-10 13:33:43 +00:00
|
|
|
errors: accountErrors {
|
|
|
|
...AccountErrorFragment
|
2019-09-03 13:42:15 +00:00
|
|
|
}
|
2020-07-23 13:37:39 +00:00
|
|
|
csrfToken
|
|
|
|
refreshToken
|
2020-03-10 13:33:43 +00:00
|
|
|
token
|
2019-09-03 13:42:15 +00:00
|
|
|
user {
|
|
|
|
...User
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
export const SetPasswordMutation = TypedMutation<
|
|
|
|
SetPassword,
|
|
|
|
SetPasswordVariables
|
|
|
|
>(setPassword);
|
2021-01-26 22:04:54 +00:00
|
|
|
|
|
|
|
export const externalAuthenticationUrlMutation = gql`
|
|
|
|
${accountErrorFragment}
|
|
|
|
mutation ExternalAuthenticationUrl($pluginId: String!, $input: JSONString!) {
|
|
|
|
externalAuthenticationUrl(pluginId: $pluginId, input: $input) {
|
|
|
|
authenticationData
|
|
|
|
errors: accountErrors {
|
|
|
|
...AccountErrorFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const externalObtainAccessTokensMutation = gql`
|
|
|
|
${accountErrorFragment}
|
|
|
|
${fragmentUser}
|
|
|
|
mutation ExternalObtainAccessTokens($pluginId: String!, $input: JSONString!) {
|
|
|
|
externalObtainAccessTokens(pluginId: $pluginId, input: $input) {
|
|
|
|
token
|
|
|
|
csrfToken
|
|
|
|
user {
|
|
|
|
...User
|
|
|
|
}
|
|
|
|
errors: accountErrors {
|
|
|
|
...AccountErrorFragment
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const externalTokenRefreshMutation = gql`
|
|
|
|
mutation ExternalRefreshToken($pluginId: String!, $input: JSONString!) {
|
|
|
|
externalRefresh(pluginId: $pluginId, input: $input) {
|
|
|
|
token
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export const externalTokenVerifyMutation = gql`
|
|
|
|
${fragmentUser}
|
|
|
|
mutation ExternalVerifyToken($pluginId: String!, $input: JSONString!) {
|
|
|
|
externalVerify(pluginId: $pluginId, input: $input) {
|
|
|
|
verifyData
|
|
|
|
user {
|
|
|
|
...User
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|