@nocios/crudify-ui 3.0.18 → 3.0.20
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/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +44 -36
- package/dist/index.mjs +44 -36
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -678,7 +678,9 @@ var SessionManager = class _SessionManager {
|
|
|
678
678
|
this.log("Login failed:", response.errors);
|
|
679
679
|
return {
|
|
680
680
|
success: false,
|
|
681
|
-
error: this.formatError(response.errors)
|
|
681
|
+
error: this.formatError(response.errors),
|
|
682
|
+
rawResponse: response
|
|
683
|
+
// Preservar respuesta original para manejo de errores específicos
|
|
682
684
|
};
|
|
683
685
|
}
|
|
684
686
|
const tokens = {
|
|
@@ -692,7 +694,9 @@ var SessionManager = class _SessionManager {
|
|
|
692
694
|
this.config.onLoginSuccess?.(tokens);
|
|
693
695
|
return {
|
|
694
696
|
success: true,
|
|
695
|
-
tokens
|
|
697
|
+
tokens,
|
|
698
|
+
data: response.data
|
|
699
|
+
// Incluir datos del usuario
|
|
696
700
|
};
|
|
697
701
|
} catch (error) {
|
|
698
702
|
this.log("Login error:", error);
|
|
@@ -927,46 +931,49 @@ function useSession(options = {}) {
|
|
|
927
931
|
}));
|
|
928
932
|
}
|
|
929
933
|
}, [options.autoRestore, options.enableLogging, options.onSessionExpired, options.onSessionRestored]);
|
|
930
|
-
const login = (0, import_react5.useCallback)(
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
934
|
+
const login = (0, import_react5.useCallback)(
|
|
935
|
+
async (email, password) => {
|
|
936
|
+
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
937
|
+
try {
|
|
938
|
+
const result = await sessionManager.login(email, password);
|
|
939
|
+
if (result.success && result.tokens) {
|
|
940
|
+
setState((prev) => ({
|
|
941
|
+
...prev,
|
|
942
|
+
isAuthenticated: true,
|
|
943
|
+
tokens: result.tokens,
|
|
944
|
+
isLoading: false,
|
|
945
|
+
error: null
|
|
946
|
+
}));
|
|
947
|
+
} else {
|
|
948
|
+
setState((prev) => ({
|
|
949
|
+
...prev,
|
|
950
|
+
isAuthenticated: false,
|
|
951
|
+
tokens: null,
|
|
952
|
+
isLoading: false,
|
|
953
|
+
error: null
|
|
954
|
+
// No establecer error global para errores de login
|
|
955
|
+
}));
|
|
956
|
+
}
|
|
957
|
+
return result;
|
|
958
|
+
} catch (error) {
|
|
959
|
+
const errorMsg = error instanceof Error ? error.message : "Login failed";
|
|
960
|
+
const isCredentialError = errorMsg.includes("INVALID_CREDENTIALS") || errorMsg.includes("Invalid email") || errorMsg.includes("Invalid password") || errorMsg.includes("credentials");
|
|
943
961
|
setState((prev) => ({
|
|
944
962
|
...prev,
|
|
945
963
|
isAuthenticated: false,
|
|
946
964
|
tokens: null,
|
|
947
965
|
isLoading: false,
|
|
948
|
-
error: null
|
|
949
|
-
//
|
|
966
|
+
error: isCredentialError ? null : errorMsg
|
|
967
|
+
// Solo errores del sistema van al estado global
|
|
950
968
|
}));
|
|
969
|
+
return {
|
|
970
|
+
success: false,
|
|
971
|
+
error: errorMsg
|
|
972
|
+
};
|
|
951
973
|
}
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
const isCredentialError = errorMsg.includes("INVALID_CREDENTIALS") || errorMsg.includes("Invalid email") || errorMsg.includes("Invalid password") || errorMsg.includes("credentials");
|
|
956
|
-
setState((prev) => ({
|
|
957
|
-
...prev,
|
|
958
|
-
isAuthenticated: false,
|
|
959
|
-
tokens: null,
|
|
960
|
-
isLoading: false,
|
|
961
|
-
error: isCredentialError ? null : errorMsg
|
|
962
|
-
// Solo errores del sistema van al estado global
|
|
963
|
-
}));
|
|
964
|
-
return {
|
|
965
|
-
success: false,
|
|
966
|
-
error: errorMsg
|
|
967
|
-
};
|
|
968
|
-
}
|
|
969
|
-
}, [sessionManager]);
|
|
974
|
+
},
|
|
975
|
+
[sessionManager]
|
|
976
|
+
);
|
|
970
977
|
const logout = (0, import_react5.useCallback)(async () => {
|
|
971
978
|
setState((prev) => ({ ...prev, isLoading: true }));
|
|
972
979
|
try {
|
|
@@ -1632,7 +1639,8 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
|
|
|
1632
1639
|
onLoginSuccess(response.data, finalRedirectUrl);
|
|
1633
1640
|
}
|
|
1634
1641
|
} else {
|
|
1635
|
-
|
|
1642
|
+
const errorToHandle = response.rawResponse || response;
|
|
1643
|
+
handleLoginError(errorToHandle);
|
|
1636
1644
|
}
|
|
1637
1645
|
} catch (error) {
|
|
1638
1646
|
setLoading(false);
|
package/dist/index.mjs
CHANGED
|
@@ -612,7 +612,9 @@ var SessionManager = class _SessionManager {
|
|
|
612
612
|
this.log("Login failed:", response.errors);
|
|
613
613
|
return {
|
|
614
614
|
success: false,
|
|
615
|
-
error: this.formatError(response.errors)
|
|
615
|
+
error: this.formatError(response.errors),
|
|
616
|
+
rawResponse: response
|
|
617
|
+
// Preservar respuesta original para manejo de errores específicos
|
|
616
618
|
};
|
|
617
619
|
}
|
|
618
620
|
const tokens = {
|
|
@@ -626,7 +628,9 @@ var SessionManager = class _SessionManager {
|
|
|
626
628
|
this.config.onLoginSuccess?.(tokens);
|
|
627
629
|
return {
|
|
628
630
|
success: true,
|
|
629
|
-
tokens
|
|
631
|
+
tokens,
|
|
632
|
+
data: response.data
|
|
633
|
+
// Incluir datos del usuario
|
|
630
634
|
};
|
|
631
635
|
} catch (error) {
|
|
632
636
|
this.log("Login error:", error);
|
|
@@ -861,46 +865,49 @@ function useSession(options = {}) {
|
|
|
861
865
|
}));
|
|
862
866
|
}
|
|
863
867
|
}, [options.autoRestore, options.enableLogging, options.onSessionExpired, options.onSessionRestored]);
|
|
864
|
-
const login = useCallback(
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
868
|
+
const login = useCallback(
|
|
869
|
+
async (email, password) => {
|
|
870
|
+
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
871
|
+
try {
|
|
872
|
+
const result = await sessionManager.login(email, password);
|
|
873
|
+
if (result.success && result.tokens) {
|
|
874
|
+
setState((prev) => ({
|
|
875
|
+
...prev,
|
|
876
|
+
isAuthenticated: true,
|
|
877
|
+
tokens: result.tokens,
|
|
878
|
+
isLoading: false,
|
|
879
|
+
error: null
|
|
880
|
+
}));
|
|
881
|
+
} else {
|
|
882
|
+
setState((prev) => ({
|
|
883
|
+
...prev,
|
|
884
|
+
isAuthenticated: false,
|
|
885
|
+
tokens: null,
|
|
886
|
+
isLoading: false,
|
|
887
|
+
error: null
|
|
888
|
+
// No establecer error global para errores de login
|
|
889
|
+
}));
|
|
890
|
+
}
|
|
891
|
+
return result;
|
|
892
|
+
} catch (error) {
|
|
893
|
+
const errorMsg = error instanceof Error ? error.message : "Login failed";
|
|
894
|
+
const isCredentialError = errorMsg.includes("INVALID_CREDENTIALS") || errorMsg.includes("Invalid email") || errorMsg.includes("Invalid password") || errorMsg.includes("credentials");
|
|
877
895
|
setState((prev) => ({
|
|
878
896
|
...prev,
|
|
879
897
|
isAuthenticated: false,
|
|
880
898
|
tokens: null,
|
|
881
899
|
isLoading: false,
|
|
882
|
-
error: null
|
|
883
|
-
//
|
|
900
|
+
error: isCredentialError ? null : errorMsg
|
|
901
|
+
// Solo errores del sistema van al estado global
|
|
884
902
|
}));
|
|
903
|
+
return {
|
|
904
|
+
success: false,
|
|
905
|
+
error: errorMsg
|
|
906
|
+
};
|
|
885
907
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
const isCredentialError = errorMsg.includes("INVALID_CREDENTIALS") || errorMsg.includes("Invalid email") || errorMsg.includes("Invalid password") || errorMsg.includes("credentials");
|
|
890
|
-
setState((prev) => ({
|
|
891
|
-
...prev,
|
|
892
|
-
isAuthenticated: false,
|
|
893
|
-
tokens: null,
|
|
894
|
-
isLoading: false,
|
|
895
|
-
error: isCredentialError ? null : errorMsg
|
|
896
|
-
// Solo errores del sistema van al estado global
|
|
897
|
-
}));
|
|
898
|
-
return {
|
|
899
|
-
success: false,
|
|
900
|
-
error: errorMsg
|
|
901
|
-
};
|
|
902
|
-
}
|
|
903
|
-
}, [sessionManager]);
|
|
908
|
+
},
|
|
909
|
+
[sessionManager]
|
|
910
|
+
);
|
|
904
911
|
const logout = useCallback(async () => {
|
|
905
912
|
setState((prev) => ({ ...prev, isLoading: true }));
|
|
906
913
|
try {
|
|
@@ -1566,7 +1573,8 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
|
|
|
1566
1573
|
onLoginSuccess(response.data, finalRedirectUrl);
|
|
1567
1574
|
}
|
|
1568
1575
|
} else {
|
|
1569
|
-
|
|
1576
|
+
const errorToHandle = response.rawResponse || response;
|
|
1577
|
+
handleLoginError(errorToHandle);
|
|
1570
1578
|
}
|
|
1571
1579
|
} catch (error) {
|
|
1572
1580
|
setLoading(false);
|