Untitled

mail@pastecode.io avatar
unknown
typescript
3 years ago
1.5 kB
2
Indexable
Never
public googleSignIn = (sendingData: googleSignParamsT, disableFormFunction: () => void): Promise<TODO_ANY> => {
    typeof disableFormFunction === 'function' && disableFormFunction();
    const { locale } = this.defaultParameters;
    const data = {
      ...sendingData,
      locale,
      'user-agent-hash': this.uaHash,
    };
    if (this.config.modules && this.config.modules.includes('error_handling_v2')) {
      return (
        this.ssoApi
          .googleSignIn(data)
          // TODO CRT-930: remove duplication with checkLeakedPassword
          .then((response) => {
            return Promise.resolve({
              ...response,
              success: true,
            });
          })
          .catch((error) => {
            return handleError(error, locale);
          })
      );
    }

    const url = this.rootPath + DEPEND_ON_ENV_ENDPOINTS.googleSignIn;
    return axios.post(url, data, { withCredentials: true });
  };

  public checkLeakedPassword = (
    password: passwordT,
    disableFormFunction: () => void,
  ): Promise<Record<string, never> | ErrorTextObject> => {
    typeof disableFormFunction === 'function' && disableFormFunction();
    return this.ssoApi
      .checkLeakedPassword(password)
      .then((response) => {
        return Promise.resolve({
          ...response,
          success: true,
        });
      })
      .catch((error) => {
        const { locale } = this.defaultParameters;
        return handleError(error, locale);
      });
  };