|
@@ -2,13 +2,13 @@ import React, {
|
|
|
useState, useEffect, useCallback,
|
|
useState, useEffect, useCallback,
|
|
|
} from 'react';
|
|
} from 'react';
|
|
|
|
|
|
|
|
-import { ErrorV3 } from '@growi/core';
|
|
|
|
|
import { useTranslation } from 'next-i18next';
|
|
import { useTranslation } from 'next-i18next';
|
|
|
import { useRouter } from 'next/router';
|
|
import { useRouter } from 'next/router';
|
|
|
import ReactCardFlip from 'react-card-flip';
|
|
import ReactCardFlip from 'react-card-flip';
|
|
|
|
|
|
|
|
import { apiv3Post } from '~/client/util/apiv3-client';
|
|
import { apiv3Post } from '~/client/util/apiv3-client';
|
|
|
import { LoginErrorCode } from '~/interfaces/errors/login-form-error';
|
|
import { LoginErrorCode } from '~/interfaces/errors/login-form-error';
|
|
|
|
|
+import { IErrorV3 } from '~/interfaces/errors/v3-error';
|
|
|
|
|
|
|
|
type LoginFormProps = {
|
|
type LoginFormProps = {
|
|
|
username?: string,
|
|
username?: string,
|
|
@@ -40,13 +40,13 @@ export const LoginForm = (props: LoginFormProps): JSX.Element => {
|
|
|
// For Login
|
|
// For Login
|
|
|
const [usernameForLogin, setUsernameForLogin] = useState('');
|
|
const [usernameForLogin, setUsernameForLogin] = useState('');
|
|
|
const [passwordForLogin, setPasswordForLogin] = useState('');
|
|
const [passwordForLogin, setPasswordForLogin] = useState('');
|
|
|
- const [loginErrors, setLoginErrors] = useState<ErrorV3[]>([]);
|
|
|
|
|
|
|
+ const [loginErrors, setLoginErrors] = useState<IErrorV3[]>([]);
|
|
|
// For Register
|
|
// For Register
|
|
|
const [usernameForRegister, setUsernameForRegister] = useState('');
|
|
const [usernameForRegister, setUsernameForRegister] = useState('');
|
|
|
const [nameForRegister, setNameForRegister] = useState('');
|
|
const [nameForRegister, setNameForRegister] = useState('');
|
|
|
const [emailForRegister, setEmailForRegister] = useState('');
|
|
const [emailForRegister, setEmailForRegister] = useState('');
|
|
|
const [passwordForRegister, setPasswordForRegister] = useState('');
|
|
const [passwordForRegister, setPasswordForRegister] = useState('');
|
|
|
- const [registerErrors, setRegisterErrors] = useState<ErrorV3[]>([]);
|
|
|
|
|
|
|
+ const [registerErrors, setRegisterErrors] = useState<IErrorV3[]>([]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
const { hash } = window.location;
|
|
const { hash } = window.location;
|
|
@@ -88,7 +88,7 @@ export const LoginForm = (props: LoginFormProps): JSX.Element => {
|
|
|
|
|
|
|
|
}, [passwordForLogin, resetLoginErrors, router, usernameForLogin]);
|
|
}, [passwordForLogin, resetLoginErrors, router, usernameForLogin]);
|
|
|
|
|
|
|
|
- const renderLoginErrors = useCallback((errors: ErrorV3[], isWithDangerouslySetinnerHtml = false) => {
|
|
|
|
|
|
|
+ const renderLoginErrors = useCallback((errors: IErrorV3[], isWithDangerouslySetinnerHtml = false) => {
|
|
|
if (errors.length === 0) return;
|
|
if (errors.length === 0) return;
|
|
|
|
|
|
|
|
return isWithDangerouslySetinnerHtml ? (
|
|
return isWithDangerouslySetinnerHtml ? (
|
|
@@ -116,8 +116,8 @@ export const LoginForm = (props: LoginFormProps): JSX.Element => {
|
|
|
const renderLocalOrLdapLoginForm = useCallback(() => {
|
|
const renderLocalOrLdapLoginForm = useCallback(() => {
|
|
|
const { isLdapStrategySetup } = props;
|
|
const { isLdapStrategySetup } = props;
|
|
|
|
|
|
|
|
- const errorsWithDangerouslySetInnerHTML: ErrorV3[] = [];
|
|
|
|
|
- const errorsWithoutDanderouslySetInnerHTML: ErrorV3[] = [];
|
|
|
|
|
|
|
+ const errorsWithDangerouslySetInnerHTML: IErrorV3[] = [];
|
|
|
|
|
+ const errorsWithoutDanderouslySetInnerHTML: IErrorV3[] = [];
|
|
|
|
|
|
|
|
loginErrors.forEach((e) => {
|
|
loginErrors.forEach((e) => {
|
|
|
if (e.code === LoginErrorCode.PROVIDER_DUPLICATED_USERNAME_EXCEPTION) {
|
|
if (e.code === LoginErrorCode.PROVIDER_DUPLICATED_USERNAME_EXCEPTION) {
|