@orbe-agro/client-core 5.6.319 → 5.6.320
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@ecme/auth/AuthProvider.js +3 -2
- package/dist/@ecme/auth/AuthProvider.js.map +1 -1
- package/dist/@ecme/components/template/Footer.js +1 -1
- package/dist/@ecme/views/auth/ForgotPassword/ForgotPassword.js +4 -2
- package/dist/@ecme/views/auth/ForgotPassword/ForgotPassword.js.map +1 -1
- package/dist/@ecme/views/auth/ForgotPassword/components/ForgotPasswordForm.js +2 -1
- package/dist/@ecme/views/auth/ForgotPassword/components/ForgotPasswordForm.js.map +1 -1
- package/dist/@ecme/views/auth/ResetPassword/ResetPassword.js +10 -5
- package/dist/@ecme/views/auth/ResetPassword/ResetPassword.js.map +1 -1
- package/dist/@ecme/views/auth/ResetPassword/components/PasswordStrengthMeter.js +50 -0
- package/dist/@ecme/views/auth/ResetPassword/components/PasswordStrengthMeter.js.map +1 -0
- package/dist/@ecme/views/auth/ResetPassword/components/ResetPasswordForm.js +28 -12
- package/dist/@ecme/views/auth/ResetPassword/components/ResetPasswordForm.js.map +1 -1
- package/dist/@ecme/views/auth/ResetPassword/politicaSenha.js +79 -0
- package/dist/@ecme/views/auth/ResetPassword/politicaSenha.js.map +1 -0
- package/dist/@ecme/views/auth/SignIn/SignIn.js +6 -0
- package/dist/@ecme/views/auth/SignIn/SignIn.js.map +1 -1
- package/dist/@ecme/views/auth/SignIn/components/SignInForm.js +9 -4
- package/dist/@ecme/views/auth/SignIn/components/SignInForm.js.map +1 -1
- package/dist/@types/@ecme/@types/auth.d.ts +1 -0
- package/dist/@types/@ecme/@types/auth.d.ts.map +1 -1
- package/dist/@types/@ecme/auth/AuthProvider.d.ts.map +1 -1
- package/dist/@types/@ecme/views/auth/ForgotPassword/ForgotPassword.d.ts.map +1 -1
- package/dist/@types/@ecme/views/auth/ForgotPassword/components/ForgotPasswordForm.d.ts +1 -0
- package/dist/@types/@ecme/views/auth/ForgotPassword/components/ForgotPasswordForm.d.ts.map +1 -1
- package/dist/@types/@ecme/views/auth/ResetPassword/ResetPassword.d.ts.map +1 -1
- package/dist/@types/@ecme/views/auth/ResetPassword/components/PasswordStrengthMeter.d.ts +6 -0
- package/dist/@types/@ecme/views/auth/ResetPassword/components/PasswordStrengthMeter.d.ts.map +1 -0
- package/dist/@types/@ecme/views/auth/ResetPassword/components/ResetPasswordForm.d.ts +1 -0
- package/dist/@types/@ecme/views/auth/ResetPassword/components/ResetPasswordForm.d.ts.map +1 -1
- package/dist/@types/@ecme/views/auth/ResetPassword/politicaSenha.d.ts +3 -0
- package/dist/@types/@ecme/views/auth/ResetPassword/politicaSenha.d.ts.map +1 -0
- package/dist/@types/@ecme/views/auth/SignIn/SignIn.d.ts.map +1 -1
- package/dist/@types/@ecme/views/auth/SignIn/components/SignInForm.d.ts +1 -0
- package/dist/@types/@ecme/views/auth/SignIn/components/SignInForm.d.ts.map +1 -1
- package/lib/@ecme/@types/auth.ts +1 -0
- package/lib/@ecme/auth/AuthProvider.tsx +2 -0
- package/lib/@ecme/views/auth/ForgotPassword/ForgotPassword.tsx +3 -1
- package/lib/@ecme/views/auth/ForgotPassword/components/ForgotPasswordForm.tsx +4 -1
- package/lib/@ecme/views/auth/ResetPassword/ResetPassword.tsx +11 -4
- package/lib/@ecme/views/auth/ResetPassword/components/PasswordStrengthMeter.tsx +60 -0
- package/lib/@ecme/views/auth/ResetPassword/components/ResetPasswordForm.tsx +28 -10
- package/lib/@ecme/views/auth/ResetPassword/politicaSenha.ts +89 -0
- package/lib/@ecme/views/auth/SignIn/SignIn.tsx +9 -0
- package/lib/@ecme/views/auth/SignIn/components/SignInForm.tsx +13 -6
- package/package.json +4 -1
|
@@ -24,7 +24,7 @@ const validationSchema = z.object({
|
|
|
24
24
|
});
|
|
25
25
|
const SignInForm = (props) => {
|
|
26
26
|
const [isSubmitting, setSubmitting] = useState(false);
|
|
27
|
-
const { disableSubmit = false, className, passwordHint } = props;
|
|
27
|
+
const { disableSubmit = false, className, setAvisoBloqueio, passwordHint } = props;
|
|
28
28
|
const {
|
|
29
29
|
handleSubmit,
|
|
30
30
|
formState: { errors },
|
|
@@ -41,11 +41,16 @@ const SignInForm = (props) => {
|
|
|
41
41
|
const { username, password } = values;
|
|
42
42
|
if (!disableSubmit) {
|
|
43
43
|
setSubmitting(true);
|
|
44
|
+
setAvisoBloqueio?.("");
|
|
44
45
|
const result = await signIn({ username, password });
|
|
45
46
|
if (result?.status === "failed") {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
if (result.httpStatus === 423) {
|
|
48
|
+
setAvisoBloqueio?.(result.message);
|
|
49
|
+
} else {
|
|
50
|
+
toast.push(
|
|
51
|
+
/* @__PURE__ */ jsx(Notification, { title: "Erro ao entrar", type: "danger", children: result.message })
|
|
52
|
+
);
|
|
53
|
+
}
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
setSubmitting(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignInForm.js","sources":["../../../../../../lib/@ecme/views/auth/SignIn/components/SignInForm.tsx"],"sourcesContent":["import { ReactNode, useState } from \"react\";\nimport Input from \"@/components/ui/Input\";\nimport Button from \"@/components/ui/Button\";\nimport Notification from \"@/components/ui/Notification\";\nimport toast from \"@/components/ui/toast\";\nimport { FormItem, Form } from \"@/components/ui/Form\";\nimport PasswordInput from \"@/components/shared/PasswordInput\";\nimport classNames from \"@/utils/classNames\";\nimport { useAuth } from \"@/auth\";\nimport { useForm, Controller } from \"react-hook-form\";\nimport { zodResolver } from \"@hookform/resolvers/zod\";\nimport { z, ZodType } from \"zod\";\nimport type { CommonProps } from \"@/@types/common\";\n\ninterface SignInFormProps extends CommonProps {\n disableSubmit?: boolean;\n passwordHint?: string | ReactNode;\n}\n\ntype SignInFormSchema = {\n username: string;\n password: string;\n};\n\nconst validationSchema: ZodType<SignInFormSchema> = z.object({\n username: z\n .string({ required_error: \"Por favor digite um login.\" })\n .min(1, { message: \"Por favor digite um login válido.\" }),\n password: z\n .string({ required_error: \"Por favor digite uma senha.\" })\n .min(1, { message: \"Por favor digite uma senha válida.\" }),\n});\n\nconst SignInForm = (props: SignInFormProps) => {\n const [isSubmitting, setSubmitting] = useState<boolean>(false);\n\n const { disableSubmit = false, className, passwordHint }
|
|
1
|
+
{"version":3,"file":"SignInForm.js","sources":["../../../../../../lib/@ecme/views/auth/SignIn/components/SignInForm.tsx"],"sourcesContent":["import { ReactNode, useState } from \"react\";\nimport Input from \"@/components/ui/Input\";\nimport Button from \"@/components/ui/Button\";\nimport Notification from \"@/components/ui/Notification\";\nimport toast from \"@/components/ui/toast\";\nimport { FormItem, Form } from \"@/components/ui/Form\";\nimport PasswordInput from \"@/components/shared/PasswordInput\";\nimport classNames from \"@/utils/classNames\";\nimport { useAuth } from \"@/auth\";\nimport { useForm, Controller } from \"react-hook-form\";\nimport { zodResolver } from \"@hookform/resolvers/zod\";\nimport { z, ZodType } from \"zod\";\nimport type { CommonProps } from \"@/@types/common\";\n\ninterface SignInFormProps extends CommonProps {\n disableSubmit?: boolean;\n passwordHint?: string | ReactNode;\n setAvisoBloqueio?: (message: string) => void;\n}\n\ntype SignInFormSchema = {\n username: string;\n password: string;\n};\n\nconst validationSchema: ZodType<SignInFormSchema> = z.object({\n username: z\n .string({ required_error: \"Por favor digite um login.\" })\n .min(1, { message: \"Por favor digite um login válido.\" }),\n password: z\n .string({ required_error: \"Por favor digite uma senha.\" })\n .min(1, { message: \"Por favor digite uma senha válida.\" }),\n});\n\nconst SignInForm = (props: SignInFormProps) => {\n const [isSubmitting, setSubmitting] = useState<boolean>(false);\n\n const { disableSubmit = false, className, setAvisoBloqueio, passwordHint } =\n props;\n\n const {\n handleSubmit,\n formState: { errors },\n control,\n } = useForm<SignInFormSchema>({\n defaultValues: {\n username: \"\",\n password: \"\",\n },\n resolver: zodResolver(validationSchema),\n });\n\n const { signIn } = useAuth();\n\n const onSignIn = async (values: SignInFormSchema) => {\n const { username, password } = values;\n\n if (!disableSubmit) {\n setSubmitting(true);\n setAvisoBloqueio?.(\"\");\n\n const result = await signIn({ username, password });\n\n if (result?.status === \"failed\") {\n if (result.httpStatus === 423) {\n setAvisoBloqueio?.(result.message);\n } else {\n toast.push(\n <Notification title=\"Erro ao entrar\" type=\"danger\">\n {result.message}\n </Notification>\n );\n }\n }\n }\n\n setSubmitting(false);\n };\n\n return (\n <div className={className}>\n <Form onSubmit={handleSubmit(onSignIn)}>\n <FormItem\n label=\"Login\"\n invalid={Boolean(errors.username)}\n errorMessage={errors.username?.message}\n >\n <Controller\n name=\"username\"\n control={control}\n render={({ field }) => (\n <Input\n type=\"text\"\n placeholder=\"Login\"\n autoComplete=\"off\"\n {...field}\n />\n )}\n />\n </FormItem>\n <FormItem\n label=\"Senha\"\n invalid={Boolean(errors.password)}\n errorMessage={errors.password?.message}\n className={classNames(\n passwordHint ? \"mb-0\" : \"\",\n errors.password?.message ? \"mb-8\" : \"\"\n )}\n >\n <Controller\n name=\"password\"\n control={control}\n rules={{ required: true }}\n render={({ field }) => (\n <PasswordInput\n type=\"text\"\n placeholder=\"Senha\"\n autoComplete=\"off\"\n {...field}\n />\n )}\n />\n </FormItem>\n {passwordHint}\n <Button\n block\n loading={isSubmitting}\n variant=\"solid\"\n type=\"submit\"\n className=\"mt-6\"\n >\n {isSubmitting ? \"Entrando...\" : \"Entrar\"}\n </Button>\n </Form>\n </div>\n );\n};\n\nexport default SignInForm;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,mBAA8C,EAAE,OAAO;AAAA,EAC3D,UAAU,EACP,OAAO,EAAE,gBAAgB,6BAAA,CAA8B,EACvD,IAAI,GAAG,EAAE,SAAS,qCAAqC;AAAA,EAC1D,UAAU,EACP,OAAO,EAAE,gBAAgB,+BAA+B,EACxD,IAAI,GAAG,EAAE,SAAS,sCAAsC;AAC7D,CAAC;AAED,MAAM,aAAa,CAAC,UAA2B;AAC7C,QA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ecme/auth/AuthProvider.tsx"],"names":[],"mappings":"AA2BA,OAAO,EAAE,SAAS,EAAoC,MAAM,OAAO,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAe,MAAM,kBAAkB,CAAA;AAGhE,KAAK,iBAAiB,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,CAAA;AAEhD,MAAM,MAAM,oBAAoB,GAAG;IAC/B,QAAQ,EAAE,gBAAgB,CAAA;CAC7B,CAAA;
|
|
1
|
+
{"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../../../../lib/@ecme/auth/AuthProvider.tsx"],"names":[],"mappings":"AA2BA,OAAO,EAAE,SAAS,EAAoC,MAAM,OAAO,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAe,MAAM,kBAAkB,CAAA;AAGhE,KAAK,iBAAiB,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,CAAA;AAEhD,MAAM,MAAM,oBAAoB,GAAG;IAC/B,QAAQ,EAAE,gBAAgB,CAAA;CAC7B,CAAA;AAgCD,iBAAS,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE,iBAAiB,2CA6NpD;AAED,eAAe,YAAY,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForgotPassword.d.ts","sourceRoot":"","sources":["../../../../../../lib/@ecme/views/auth/ForgotPassword/ForgotPassword.tsx"],"names":[],"mappings":"AAQA,eAAO,MAAM,kBAAkB,+
|
|
1
|
+
{"version":3,"file":"ForgotPassword.d.ts","sourceRoot":"","sources":["../../../../../../lib/@ecme/views/auth/ForgotPassword/ForgotPassword.tsx"],"names":[],"mappings":"AAQA,eAAO,MAAM,kBAAkB,+CAkC9B,CAAA;AAED,QAAA,MAAM,cAAc,+CAEnB,CAAA;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -3,6 +3,7 @@ interface ForgotPasswordFormProps extends CommonProps {
|
|
|
3
3
|
emailSent: boolean;
|
|
4
4
|
setEmailSent?: (compplete: boolean) => void;
|
|
5
5
|
setMessage?: (message: string) => void;
|
|
6
|
+
setEmail?: (email: string) => void;
|
|
6
7
|
}
|
|
7
8
|
declare const ForgotPasswordForm: (props: ForgotPasswordFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export default ForgotPasswordForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForgotPasswordForm.d.ts","sourceRoot":"","sources":["../../../../../../../lib/@ecme/views/auth/ForgotPassword/components/ForgotPasswordForm.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAElD,UAAU,uBAAwB,SAAQ,WAAW;IACjD,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAA;IAC3C,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"ForgotPasswordForm.d.ts","sourceRoot":"","sources":["../../../../../../../lib/@ecme/views/auth/ForgotPassword/components/ForgotPasswordForm.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAElD,UAAU,uBAAwB,SAAQ,WAAW;IACjD,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAA;IAC3C,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CACrC;AAUD,QAAA,MAAM,kBAAkB,GAAI,OAAO,uBAAuB,4CAqEzD,CAAA;AAED,eAAe,kBAAkB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResetPassword.d.ts","sourceRoot":"","sources":["../../../../../../lib/@ecme/views/auth/ResetPassword/ResetPassword.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ResetPassword.d.ts","sourceRoot":"","sources":["../../../../../../lib/@ecme/views/auth/ResetPassword/ResetPassword.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAMhE,KAAK,kBAAkB,GAAG;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,oBAAoB,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,sBAG/B,kBAAkB,4CA+EpB,CAAC;AAEF,QAAA,MAAM,aAAa,+CAElB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
interface PasswordStrengthMeterProps {
|
|
2
|
+
password?: string;
|
|
3
|
+
}
|
|
4
|
+
declare const PasswordStrengthMeter: ({ password }: PasswordStrengthMeterProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
5
|
+
export default PasswordStrengthMeter;
|
|
6
|
+
//# sourceMappingURL=PasswordStrengthMeter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PasswordStrengthMeter.d.ts","sourceRoot":"","sources":["../../../../../../../lib/@ecme/views/auth/ResetPassword/components/PasswordStrengthMeter.tsx"],"names":[],"mappings":"AAcA,UAAU,0BAA0B;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,QAAA,MAAM,qBAAqB,GAAI,cAAc,0BAA0B,mDAuCtE,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -6,6 +6,7 @@ interface ResetPasswordFormProps extends CommonProps {
|
|
|
6
6
|
setMessage?: (message: string) => void;
|
|
7
7
|
type: TAlterarPasswordType;
|
|
8
8
|
userId?: string;
|
|
9
|
+
email?: string;
|
|
9
10
|
}
|
|
10
11
|
declare const ResetPasswordForm: (props: ResetPasswordFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export default ResetPasswordForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResetPasswordForm.d.ts","sourceRoot":"","sources":["../../../../../../../lib/@ecme/views/auth/ResetPassword/components/ResetPasswordForm.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"ResetPasswordForm.d.ts","sourceRoot":"","sources":["../../../../../../../lib/@ecme/views/auth/ResetPassword/components/ResetPasswordForm.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAUhE,UAAU,sBAAuB,SAAQ,WAAW;IAClD,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAsBD,QAAA,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,4CA0JvD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const calcularNotaSenha: (senha: string) => Promise<import("@zxcvbn-ts/core").Score>;
|
|
2
|
+
export declare const validarPoliticaSenha: (senha: string) => Promise<"A senha deve ter entre 8 e 50 caracteres." | "Senha muito longa." | "A senha não pode conter espaços." | "A senha não pode ter sequências como 1234, 4321 ou abcd." | "Senha muito fraca." | undefined>;
|
|
3
|
+
//# sourceMappingURL=politicaSenha.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"politicaSenha.d.ts","sourceRoot":"","sources":["../../../../../../lib/@ecme/views/auth/ResetPassword/politicaSenha.ts"],"names":[],"mappings":"AAgCA,eAAO,MAAM,iBAAiB,GAAU,OAAO,MAAM,6CACR,CAAC;AAuC9C,eAAO,MAAM,oBAAoB,GAAU,OAAO,MAAM,qNAgBvD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignIn.d.ts","sourceRoot":"","sources":["../../../../../../lib/@ecme/views/auth/SignIn/SignIn.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SignIn.d.ts","sourceRoot":"","sources":["../../../../../../lib/@ecme/views/auth/SignIn/SignIn.tsx"],"names":[],"mappings":"AAQA,KAAK,WAAW,GAAG;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,kDAIxB,WAAW,4CAsCb,CAAA;AAED,QAAA,MAAM,MAAM,+CAEX,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -3,6 +3,7 @@ import type { CommonProps } from "@/@types/common";
|
|
|
3
3
|
interface SignInFormProps extends CommonProps {
|
|
4
4
|
disableSubmit?: boolean;
|
|
5
5
|
passwordHint?: string | ReactNode;
|
|
6
|
+
setAvisoBloqueio?: (message: string) => void;
|
|
6
7
|
}
|
|
7
8
|
declare const SignInForm: (props: SignInFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export default SignInForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignInForm.d.ts","sourceRoot":"","sources":["../../../../../../../lib/@ecme/views/auth/SignIn/components/SignInForm.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAY5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,UAAU,eAAgB,SAAQ,WAAW;IAC3C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"SignInForm.d.ts","sourceRoot":"","sources":["../../../../../../../lib/@ecme/views/auth/SignIn/components/SignInForm.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAY5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,UAAU,eAAgB,SAAQ,WAAW;IAC3C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C;AAgBD,QAAA,MAAM,UAAU,GAAI,OAAO,eAAe,4CAsGzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/lib/@ecme/@types/auth.ts
CHANGED
|
@@ -58,6 +58,7 @@ const getSignInErrorMessage = (error: any): string => {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
return (
|
|
61
|
+
response.data?.detail ||
|
|
61
62
|
SIGN_IN_ERROR_MESSAGES_BY_STATUS[response.status] ||
|
|
62
63
|
response.data?.message ||
|
|
63
64
|
SIGN_IN_DEFAULT_ERROR_MESSAGE
|
|
@@ -201,6 +202,7 @@ function AuthProvider({ children }: AuthProviderProps) {
|
|
|
201
202
|
return {
|
|
202
203
|
status: 'failed',
|
|
203
204
|
message: getSignInErrorMessage(errors),
|
|
205
|
+
httpStatus: errors?.response?.status,
|
|
204
206
|
}
|
|
205
207
|
}
|
|
206
208
|
}
|
|
@@ -8,12 +8,13 @@ import ForgotPasswordForm from './components/ForgotPasswordForm'
|
|
|
8
8
|
|
|
9
9
|
export const ForgotPasswordBase = () => {
|
|
10
10
|
const [emailSent, setEmailSent] = useState(false)
|
|
11
|
+
const [email, setEmail] = useState('')
|
|
11
12
|
const [message, setMessage] = useTimeOutMessage()
|
|
12
13
|
|
|
13
14
|
const { t } = useTranslation()
|
|
14
15
|
|
|
15
16
|
if (emailSent) {
|
|
16
|
-
return <Navigate replace to="/reset-password" />
|
|
17
|
+
return <Navigate replace to="/reset-password" state={{ email }} />
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
return (
|
|
@@ -35,6 +36,7 @@ export const ForgotPasswordBase = () => {
|
|
|
35
36
|
emailSent={emailSent}
|
|
36
37
|
setMessage={setMessage}
|
|
37
38
|
setEmailSent={setEmailSent}
|
|
39
|
+
setEmail={setEmail}
|
|
38
40
|
/>
|
|
39
41
|
</div>
|
|
40
42
|
)
|
|
@@ -13,6 +13,7 @@ interface ForgotPasswordFormProps extends CommonProps {
|
|
|
13
13
|
emailSent: boolean
|
|
14
14
|
setEmailSent?: (compplete: boolean) => void
|
|
15
15
|
setMessage?: (message: string) => void
|
|
16
|
+
setEmail?: (email: string) => void
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
type ForgotPasswordFormSchema = {
|
|
@@ -26,7 +27,8 @@ const validationSchema: ZodType<ForgotPasswordFormSchema> = z.object({
|
|
|
26
27
|
const ForgotPasswordForm = (props: ForgotPasswordFormProps) => {
|
|
27
28
|
const [isSubmitting, setSubmitting] = useState<boolean>(false)
|
|
28
29
|
|
|
29
|
-
const { className, setMessage, setEmailSent, emailSent, children } =
|
|
30
|
+
const { className, setMessage, setEmailSent, setEmail, emailSent, children } =
|
|
31
|
+
props
|
|
30
32
|
|
|
31
33
|
const {
|
|
32
34
|
handleSubmit,
|
|
@@ -44,6 +46,7 @@ const ForgotPasswordForm = (props: ForgotPasswordFormProps) => {
|
|
|
44
46
|
try {
|
|
45
47
|
await apiForgotPassword({ email })
|
|
46
48
|
setSubmitting(false)
|
|
49
|
+
setEmail?.(email)
|
|
47
50
|
setEmailSent?.(true)
|
|
48
51
|
} catch (errors) {
|
|
49
52
|
setMessage?.(
|
|
@@ -3,8 +3,7 @@ import Alert from "@/components/ui/Alert";
|
|
|
3
3
|
import Button from "@/components/ui/Button";
|
|
4
4
|
import ActionLink from "@/components/shared/ActionLink";
|
|
5
5
|
import ResetPasswordForm from "./components/ResetPasswordForm";
|
|
6
|
-
import
|
|
7
|
-
import { useNavigate } from "react-router-dom";
|
|
6
|
+
import { Navigate, useLocation, useNavigate } from "react-router-dom";
|
|
8
7
|
import { TAlterarPasswordType } from "@base/@types/models/auth";
|
|
9
8
|
import Logo from "@/components/template/Logo";
|
|
10
9
|
import { getLogoFilename } from "@base/utils";
|
|
@@ -22,7 +21,7 @@ export const ResetPasswordBase = ({
|
|
|
22
21
|
}: ResetPasswordProps) => {
|
|
23
22
|
const [resetComplete, setResetComplete] = useState(false);
|
|
24
23
|
|
|
25
|
-
const [message, setMessage] =
|
|
24
|
+
const [message, setMessage] = useState("");
|
|
26
25
|
|
|
27
26
|
const navigate = useNavigate();
|
|
28
27
|
|
|
@@ -32,6 +31,12 @@ export const ResetPasswordBase = ({
|
|
|
32
31
|
|
|
33
32
|
const { mode } = useThemeStore();
|
|
34
33
|
const { user } = useAuth();
|
|
34
|
+
const { state } = useLocation();
|
|
35
|
+
const email = (state as { email?: string } | null)?.email;
|
|
36
|
+
|
|
37
|
+
if (type === "RECUPERARSENHA" && !email) {
|
|
38
|
+
return <Navigate replace to="/forgot-password" />;
|
|
39
|
+
}
|
|
35
40
|
|
|
36
41
|
return (
|
|
37
42
|
<div>
|
|
@@ -47,7 +52,8 @@ export const ResetPasswordBase = ({
|
|
|
47
52
|
<>
|
|
48
53
|
<h3 className="mb-2">Crie sua nova senha</h3>
|
|
49
54
|
<p className="font-semibold">
|
|
50
|
-
|
|
55
|
+
Verifique seu e-mail. Você receberá um código de 6 dígitos.
|
|
56
|
+
Informe o código e crie sua nova senha.
|
|
51
57
|
</p>
|
|
52
58
|
</>
|
|
53
59
|
) : (
|
|
@@ -74,6 +80,7 @@ export const ResetPasswordBase = ({
|
|
|
74
80
|
setResetComplete={setResetComplete}
|
|
75
81
|
type={type}
|
|
76
82
|
userId={user.userId ?? undefined}
|
|
83
|
+
email={email}
|
|
77
84
|
>
|
|
78
85
|
<Button block variant="solid" type="button" onClick={handleContinue}>
|
|
79
86
|
Continuar
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import classNames from "@/utils/classNames";
|
|
3
|
+
import { calcularNotaSenha } from "../politicaSenha";
|
|
4
|
+
|
|
5
|
+
const NIVEIS = [
|
|
6
|
+
{ label: "Muito fraca", cor: "bg-error" },
|
|
7
|
+
{ label: "Fraca", cor: "bg-error" },
|
|
8
|
+
{ label: "Fraca", cor: "bg-error" },
|
|
9
|
+
{ label: "Boa", cor: "bg-success" },
|
|
10
|
+
{ label: "Forte", cor: "bg-success" },
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
const SEGMENTOS = [1, 2, 3, 4];
|
|
14
|
+
|
|
15
|
+
interface PasswordStrengthMeterProps {
|
|
16
|
+
password?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const PasswordStrengthMeter = ({ password }: PasswordStrengthMeterProps) => {
|
|
20
|
+
const [nota, setNota] = useState<number | null>(null);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!password) {
|
|
24
|
+
setNota(null);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
let ativo = true;
|
|
28
|
+
calcularNotaSenha(password)
|
|
29
|
+
.then((novaNota) => ativo && setNota(novaNota))
|
|
30
|
+
.catch(() => ativo && setNota(null));
|
|
31
|
+
return () => {
|
|
32
|
+
ativo = false;
|
|
33
|
+
};
|
|
34
|
+
}, [password]);
|
|
35
|
+
|
|
36
|
+
if (!password || nota === null) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const nivel = NIVEIS[nota];
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div className="mt-2">
|
|
44
|
+
<div className="flex gap-1">
|
|
45
|
+
{SEGMENTOS.map((segmento) => (
|
|
46
|
+
<div
|
|
47
|
+
key={segmento}
|
|
48
|
+
className={classNames(
|
|
49
|
+
"h-1.5 flex-1 rounded-full",
|
|
50
|
+
segmento <= nota ? nivel.cor : "bg-gray-200 dark:bg-gray-600"
|
|
51
|
+
)}
|
|
52
|
+
/>
|
|
53
|
+
))}
|
|
54
|
+
</div>
|
|
55
|
+
<p className="mt-1 text-xs">Força da senha: {nivel.label}</p>
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default PasswordStrengthMeter;
|
|
@@ -15,6 +15,9 @@ import { useNavigate } from "react-router-dom";
|
|
|
15
15
|
import appConfig from "@/configs/app.config";
|
|
16
16
|
import { useThemeStore } from "@/store/themeStore";
|
|
17
17
|
import { LAYOUT_COLLAPSIBLE_SIDE } from "@/constants/theme.constant";
|
|
18
|
+
import { isAxiosError } from "axios";
|
|
19
|
+
import PasswordStrengthMeter from "./PasswordStrengthMeter";
|
|
20
|
+
import { validarPoliticaSenha } from "../politicaSenha";
|
|
18
21
|
|
|
19
22
|
interface ResetPasswordFormProps extends CommonProps {
|
|
20
23
|
resetComplete: boolean;
|
|
@@ -22,6 +25,7 @@ interface ResetPasswordFormProps extends CommonProps {
|
|
|
22
25
|
setMessage?: (message: string) => void;
|
|
23
26
|
type: TAlterarPasswordType;
|
|
24
27
|
userId?: string;
|
|
28
|
+
email?: string;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
type ResetPasswordFormSchema = {
|
|
@@ -58,11 +62,13 @@ const ResetPasswordForm = (props: ResetPasswordFormProps) => {
|
|
|
58
62
|
children,
|
|
59
63
|
type,
|
|
60
64
|
userId,
|
|
65
|
+
email,
|
|
61
66
|
} = props;
|
|
62
67
|
|
|
63
68
|
const {
|
|
64
69
|
handleSubmit,
|
|
65
70
|
formState: { errors },
|
|
71
|
+
setError,
|
|
66
72
|
control,
|
|
67
73
|
} = useForm<ResetPasswordFormSchema>({
|
|
68
74
|
resolver: zodResolver(
|
|
@@ -72,7 +78,7 @@ const ResetPasswordForm = (props: ResetPasswordFormProps) => {
|
|
|
72
78
|
token: z
|
|
73
79
|
.string({ required_error: "Informe o código recebido por e-mail." })
|
|
74
80
|
.trim()
|
|
75
|
-
.
|
|
81
|
+
.regex(/^\d{6}$/, "Informe o código de 6 dígitos recebido por e-mail."),
|
|
76
82
|
})
|
|
77
83
|
)
|
|
78
84
|
: validationSchema
|
|
@@ -81,15 +87,23 @@ const ResetPasswordForm = (props: ResetPasswordFormProps) => {
|
|
|
81
87
|
|
|
82
88
|
const onResetPassword = async (values: ResetPasswordFormSchema) => {
|
|
83
89
|
const { newPassword, token } = values;
|
|
90
|
+
setMessage?.("");
|
|
84
91
|
setSubmitting(true);
|
|
85
92
|
|
|
93
|
+
const erroSenha = await validarPoliticaSenha(newPassword);
|
|
94
|
+
if (erroSenha) {
|
|
95
|
+
setError("newPassword", { message: erroSenha });
|
|
96
|
+
setSubmitting(false);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
86
100
|
try {
|
|
87
101
|
let payload;
|
|
88
102
|
if (type === "RECUPERARSENHA") {
|
|
89
103
|
if (!token) {
|
|
90
104
|
throw new Error("Token de recuperação não fornecido.");
|
|
91
105
|
}
|
|
92
|
-
payload = { token, password: newPassword };
|
|
106
|
+
payload = { email, token, password: newPassword };
|
|
93
107
|
} else {
|
|
94
108
|
payload = { id: userId ?? "", password: newPassword };
|
|
95
109
|
}
|
|
@@ -102,9 +116,9 @@ const ResetPasswordForm = (props: ResetPasswordFormProps) => {
|
|
|
102
116
|
navigate(appConfig.authenticatedEntryPath);
|
|
103
117
|
} catch (errors) {
|
|
104
118
|
setMessage?.(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
119
|
+
(isAxiosError<{ detail?: string }>(errors) &&
|
|
120
|
+
errors.response?.data?.detail) ||
|
|
121
|
+
"Houve um erro ao alterar sua senha."
|
|
108
122
|
);
|
|
109
123
|
setSubmitting(false);
|
|
110
124
|
}
|
|
@@ -128,6 +142,7 @@ const ResetPasswordForm = (props: ResetPasswordFormProps) => {
|
|
|
128
142
|
render={({ field }) => (
|
|
129
143
|
<Input
|
|
130
144
|
autoComplete="off"
|
|
145
|
+
inputMode="numeric"
|
|
131
146
|
placeholder="Código recebido por e-mail"
|
|
132
147
|
{...field}
|
|
133
148
|
/>
|
|
@@ -144,11 +159,14 @@ const ResetPasswordForm = (props: ResetPasswordFormProps) => {
|
|
|
144
159
|
name="newPassword"
|
|
145
160
|
control={control}
|
|
146
161
|
render={({ field }) => (
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
162
|
+
<>
|
|
163
|
+
<PasswordInput
|
|
164
|
+
autoComplete="off"
|
|
165
|
+
placeholder="••••••••••••"
|
|
166
|
+
{...field}
|
|
167
|
+
/>
|
|
168
|
+
<PasswordStrengthMeter password={field.value} />
|
|
169
|
+
</>
|
|
152
170
|
)}
|
|
153
171
|
/>
|
|
154
172
|
</FormItem>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ZxcvbnFactory } from "@zxcvbn-ts/core";
|
|
2
|
+
|
|
3
|
+
const TAMANHO_MINIMO = 8;
|
|
4
|
+
const TAMANHO_MAXIMO = 50;
|
|
5
|
+
const BYTES_MAXIMO = 72;
|
|
6
|
+
const TAMANHO_SEQUENCIA_PROIBIDA = 4;
|
|
7
|
+
const NOTA_MINIMA = 3;
|
|
8
|
+
const SENHA_PROIBIDA = "cereal@123";
|
|
9
|
+
|
|
10
|
+
let zxcvbn: Promise<ZxcvbnFactory> | undefined;
|
|
11
|
+
|
|
12
|
+
const carregarZxcvbn = () => {
|
|
13
|
+
zxcvbn ??= Promise.all([
|
|
14
|
+
import("@zxcvbn-ts/core"),
|
|
15
|
+
import("@zxcvbn-ts/language-common"),
|
|
16
|
+
import("@zxcvbn-ts/language-pt-br"),
|
|
17
|
+
])
|
|
18
|
+
.then(
|
|
19
|
+
([core, common, ptBr]) =>
|
|
20
|
+
new core.ZxcvbnFactory({
|
|
21
|
+
dictionary: { ...common.dictionary, ...ptBr.dictionary },
|
|
22
|
+
graphs: common.adjacencyGraphs,
|
|
23
|
+
translations: ptBr.translations,
|
|
24
|
+
})
|
|
25
|
+
)
|
|
26
|
+
.catch((erro) => {
|
|
27
|
+
zxcvbn = undefined;
|
|
28
|
+
throw erro;
|
|
29
|
+
});
|
|
30
|
+
return zxcvbn;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const calcularNotaSenha = async (senha: string) =>
|
|
34
|
+
(await carregarZxcvbn()).check(senha).score;
|
|
35
|
+
|
|
36
|
+
const possuiSequencia = (senha: string) => {
|
|
37
|
+
let crescente = 1;
|
|
38
|
+
let decrescente = 1;
|
|
39
|
+
for (let i = 1; i < senha.length; i++) {
|
|
40
|
+
const anterior = senha.charAt(i - 1);
|
|
41
|
+
const atual = senha.charAt(i);
|
|
42
|
+
const mesmoTipo = /^(?:[0-9]{2}|[a-z]{2})$/.test(anterior + atual);
|
|
43
|
+
const diferenca = atual.charCodeAt(0) - anterior.charCodeAt(0);
|
|
44
|
+
crescente = mesmoTipo && diferenca === 1 ? crescente + 1 : 1;
|
|
45
|
+
decrescente = mesmoTipo && diferenca === -1 ? decrescente + 1 : 1;
|
|
46
|
+
if (
|
|
47
|
+
crescente >= TAMANHO_SEQUENCIA_PROIBIDA ||
|
|
48
|
+
decrescente >= TAMANHO_SEQUENCIA_PROIBIDA
|
|
49
|
+
) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const validarFormatoSenha = (senha: string) => {
|
|
57
|
+
const tamanho = [...senha].length;
|
|
58
|
+
if (tamanho < TAMANHO_MINIMO || tamanho > TAMANHO_MAXIMO) {
|
|
59
|
+
return "A senha deve ter entre 8 e 50 caracteres.";
|
|
60
|
+
}
|
|
61
|
+
if (new TextEncoder().encode(senha).length > BYTES_MAXIMO) {
|
|
62
|
+
return "Senha muito longa.";
|
|
63
|
+
}
|
|
64
|
+
if (/\s/.test(senha)) {
|
|
65
|
+
return "A senha não pode conter espaços.";
|
|
66
|
+
}
|
|
67
|
+
if (possuiSequencia(senha.toLowerCase())) {
|
|
68
|
+
return "A senha não pode ter sequências como 1234, 4321 ou abcd.";
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const validarPoliticaSenha = async (senha: string) => {
|
|
74
|
+
const erroFormato = validarFormatoSenha(senha);
|
|
75
|
+
if (erroFormato) {
|
|
76
|
+
return erroFormato;
|
|
77
|
+
}
|
|
78
|
+
if (senha.toLowerCase() === SENHA_PROIBIDA) {
|
|
79
|
+
return "Senha muito fraca.";
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
if ((await calcularNotaSenha(senha)) < NOTA_MINIMA) {
|
|
83
|
+
return "Senha muito fraca.";
|
|
84
|
+
}
|
|
85
|
+
} catch {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import ActionLink from '@/components/shared/ActionLink'
|
|
2
|
+
import Alert from '@/components/ui/Alert'
|
|
3
|
+
import { useState } from 'react'
|
|
2
4
|
import SignInForm from './components/SignInForm'
|
|
3
5
|
import Logo from '@/components/template/Logo'
|
|
4
6
|
import { getLogoFilename } from '@base/utils/logo'
|
|
@@ -15,6 +17,7 @@ export const SignInBase = ({
|
|
|
15
17
|
forgetPasswordUrl = '/forgot-password',
|
|
16
18
|
disableSubmit,
|
|
17
19
|
}: SignInProps) => {
|
|
20
|
+
const [avisoBloqueio, setAvisoBloqueio] = useState('')
|
|
18
21
|
const { mode } = useThemeStore()
|
|
19
22
|
|
|
20
23
|
return (
|
|
@@ -29,8 +32,14 @@ export const SignInBase = ({
|
|
|
29
32
|
Digite seus dados para entrar.
|
|
30
33
|
</p>
|
|
31
34
|
</div>
|
|
35
|
+
{avisoBloqueio && (
|
|
36
|
+
<Alert showIcon className="mb-4" type="warning">
|
|
37
|
+
{avisoBloqueio}
|
|
38
|
+
</Alert>
|
|
39
|
+
)}
|
|
32
40
|
<SignInForm
|
|
33
41
|
disableSubmit={disableSubmit}
|
|
42
|
+
setAvisoBloqueio={setAvisoBloqueio}
|
|
34
43
|
passwordHint={
|
|
35
44
|
<div className="mb-6 mt-2">
|
|
36
45
|
<ActionLink
|
|
@@ -15,6 +15,7 @@ import type { CommonProps } from "@/@types/common";
|
|
|
15
15
|
interface SignInFormProps extends CommonProps {
|
|
16
16
|
disableSubmit?: boolean;
|
|
17
17
|
passwordHint?: string | ReactNode;
|
|
18
|
+
setAvisoBloqueio?: (message: string) => void;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
type SignInFormSchema = {
|
|
@@ -34,7 +35,8 @@ const validationSchema: ZodType<SignInFormSchema> = z.object({
|
|
|
34
35
|
const SignInForm = (props: SignInFormProps) => {
|
|
35
36
|
const [isSubmitting, setSubmitting] = useState<boolean>(false);
|
|
36
37
|
|
|
37
|
-
const { disableSubmit = false, className, passwordHint } =
|
|
38
|
+
const { disableSubmit = false, className, setAvisoBloqueio, passwordHint } =
|
|
39
|
+
props;
|
|
38
40
|
|
|
39
41
|
const {
|
|
40
42
|
handleSubmit,
|
|
@@ -55,15 +57,20 @@ const SignInForm = (props: SignInFormProps) => {
|
|
|
55
57
|
|
|
56
58
|
if (!disableSubmit) {
|
|
57
59
|
setSubmitting(true);
|
|
60
|
+
setAvisoBloqueio?.("");
|
|
58
61
|
|
|
59
62
|
const result = await signIn({ username, password });
|
|
60
63
|
|
|
61
64
|
if (result?.status === "failed") {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
if (result.httpStatus === 423) {
|
|
66
|
+
setAvisoBloqueio?.(result.message);
|
|
67
|
+
} else {
|
|
68
|
+
toast.push(
|
|
69
|
+
<Notification title="Erro ao entrar" type="danger">
|
|
70
|
+
{result.message}
|
|
71
|
+
</Notification>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
67
74
|
}
|
|
68
75
|
}
|
|
69
76
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbe-agro/client-core",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.320",
|
|
4
4
|
"description": "Biblioteca principal de componentes e utilidades para os microfrontends do Orbe Agro.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -76,6 +76,9 @@
|
|
|
76
76
|
"@types/d3-geo": "^3.1.0",
|
|
77
77
|
"@visx/pattern": "^3.13.0-alpha.0",
|
|
78
78
|
"@wyw-in-js/babel-preset": "^0.5.5",
|
|
79
|
+
"@zxcvbn-ts/core": "^4.2.0",
|
|
80
|
+
"@zxcvbn-ts/language-common": "^4.1.3",
|
|
81
|
+
"@zxcvbn-ts/language-pt-br": "^4.1.1",
|
|
79
82
|
"antd": "^5.26.7",
|
|
80
83
|
"apexcharts": "^5.10.3",
|
|
81
84
|
"axios": "^1.7.7",
|