@micha.bigler/ui-core-micha 2.1.19 → 2.1.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.
@@ -16,7 +16,7 @@ import { MfaLoginComponent } from '../components/MfaLoginComponent';
16
16
  export function LoginPage() {
17
17
  const navigate = useNavigate();
18
18
  const location = useLocation();
19
- const { login, authMethods } = useContext(AuthContext);
19
+ const { user, loading, login, authMethods } = useContext(AuthContext);
20
20
  const { t } = useTranslation();
21
21
  // State
22
22
  const [step, setStep] = useState('credentials'); // 'credentials' | 'mfa'
@@ -38,6 +38,18 @@ export function LoginPage() {
38
38
  setErrorKey('Auth.SOCIAL_LOGIN_FAILED');
39
39
  }
40
40
  }, [location.search]);
41
+ useEffect(() => {
42
+ var _a;
43
+ if (loading || !user)
44
+ return;
45
+ const requiresExtra = ((_a = user.security_state) === null || _a === void 0 ? void 0 : _a.requires_additional_security) === true;
46
+ if (requiresExtra) {
47
+ navigate('/account?tab=security&from=weak_login', { replace: true });
48
+ }
49
+ else {
50
+ navigate('/', { replace: true });
51
+ }
52
+ }, [loading, user, navigate]);
41
53
  // --- Helper: Central Success Logic ---
42
54
  const handleLoginSuccess = (user) => {
43
55
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micha.bigler/ui-core-micha",
3
- "version": "2.1.19",
3
+ "version": "2.1.20",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "private": false,
@@ -19,7 +19,7 @@ import { MfaLoginComponent } from '../components/MfaLoginComponent';
19
19
  export function LoginPage() {
20
20
  const navigate = useNavigate();
21
21
  const location = useLocation();
22
- const { login, authMethods } = useContext(AuthContext);
22
+ const { user, loading, login, authMethods } = useContext(AuthContext);
23
23
  const { t } = useTranslation();
24
24
 
25
25
  // State
@@ -47,6 +47,17 @@ export function LoginPage() {
47
47
  }
48
48
  }, [location.search]);
49
49
 
50
+ useEffect(() => {
51
+ if (loading || !user) return;
52
+
53
+ const requiresExtra = user.security_state?.requires_additional_security === true;
54
+ if (requiresExtra) {
55
+ navigate('/account?tab=security&from=weak_login', { replace: true });
56
+ } else {
57
+ navigate('/', { replace: true });
58
+ }
59
+ }, [loading, user, navigate]);
60
+
50
61
  // --- Helper: Central Success Logic ---
51
62
  const handleLoginSuccess = (user) => {
52
63
  login(user); // Update Context