mirror of
https://github.com/jambonz/jambonz-webapp.git
synced 2026-10-27 13:54:22 +00:00
check reroute when logging in
This commit is contained in:
1 parent
ccefb37f20
commit
70c1c416a2
2 files changed
+10
-3
No files matched your search
@@ -203,7 +203,7 @@ export const UserForm = ({ user }: UserFormProps) => {
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{scope !== USER_ACCOUNT && !hasLength(accounts) && (
|
||||
{scope === USER_ACCOUNT && !hasLength(accounts) && (
|
||||
<>
|
||||
<label htmlFor="account">
|
||||
Account:<span>*</span>
|
||||
|
||||
@@ -2,18 +2,21 @@ import React, { useEffect, useState } from "react";
|
||||
import { Button, H1 } from "jambonz-ui";
|
||||
import { useLocation, Navigate } from "react-router-dom";
|
||||
|
||||
import { toastError } from "src/store";
|
||||
import { toastError, useSelectState } from "src/store";
|
||||
import { useAuth } from "src/router/auth";
|
||||
import { SESS_UNAUTHORIZED, SESS_OLD_PASSWORD } from "src/constants";
|
||||
import { Passwd, Message } from "src/components/forms";
|
||||
import {
|
||||
ROUTE_INTERNAL_ACCOUNTS,
|
||||
ROUTE_CREATE_PASSWORD,
|
||||
ROUTE_INTERNAL_APPLICATIONS,
|
||||
} from "src/router/routes";
|
||||
import { USER_ACCOUNT } from "src/api/constants";
|
||||
|
||||
export const Login = () => {
|
||||
const { signin, authorized } = useAuth();
|
||||
const location = useLocation();
|
||||
const user = useSelectState("user");
|
||||
const [username, setUsername] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [message, setMessage] = useState("");
|
||||
@@ -49,7 +52,11 @@ export const Login = () => {
|
||||
|
||||
return (
|
||||
<Navigate
|
||||
to={ROUTE_INTERNAL_ACCOUNTS}
|
||||
to={
|
||||
user?.scope !== USER_ACCOUNT
|
||||
? ROUTE_INTERNAL_ACCOUNTS
|
||||
: ROUTE_INTERNAL_APPLICATIONS
|
||||
}
|
||||
state={{ from: location }}
|
||||
replace
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user