9 files changed
+314
-316
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 2.8 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 89 KiB |
@@ -114,7 +114,7 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
style={{ flex: 1 }}
|
style={{ flex: 1 }}
|
||||||
onClick={initQuickConnect.mutate}
|
onClick={initQuickConnect.mutate}
|
||||||
>
|
>
|
||||||
Quick Connect
|
Use Quick Connect
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
<Dialog
|
<Dialog
|
||||||
open={Boolean(quickConnectCode)}
|
open={Boolean(quickConnectCode)}
|
||||||
|
|||||||
@@ -262,8 +262,8 @@ export const Route = createRootRouteWithContext<ApiContext>()({
|
|||||||
<AppBar />
|
<AppBar />
|
||||||
<AudioPlayer />
|
<AudioPlayer />
|
||||||
<Outlet />
|
<Outlet />
|
||||||
{/* <ReactQueryDevtools /> */}
|
<ReactQueryDevtools />
|
||||||
{/* <TanStackRouterDevtools /> */}
|
<TanStackRouterDevtools />
|
||||||
</SnackbarProvider>
|
</SnackbarProvider>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
|||||||
+10
-14
@@ -1,6 +1,6 @@
|
|||||||
|
import { AppBarBackOnly } from "@/components/appBar/backOnly";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
import { CircularProgress, Typography } from "@mui/material";
|
import { Outlet, createFileRoute, redirect } from "@tanstack/react-router";
|
||||||
import { createFileRoute, redirect } from "@tanstack/react-router";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/login")({
|
export const Route = createFileRoute("/_api/login")({
|
||||||
@@ -19,16 +19,12 @@ export const Route = createFileRoute("/_api/login")({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// component: () => {
|
component: () => {
|
||||||
// const data = Route.useRouteContext();
|
return (
|
||||||
// console.log(data);
|
<>
|
||||||
// return (
|
<AppBarBackOnly />
|
||||||
// <div style={{ height: "100vh" }} className="flex flex-column flex-center">
|
<Outlet />
|
||||||
// <CircularProgress size={86} thickness={2} />
|
</>
|
||||||
// <Typography mt={4} align="center">
|
);
|
||||||
// Fetching users...
|
},
|
||||||
// </Typography>
|
|
||||||
// </div>
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
});
|
});
|
||||||
@@ -1,51 +1,68 @@
|
|||||||
import LoadingButton from "@mui/lab/LoadingButton";
|
import LoadingButton from "@mui/lab/LoadingButton";
|
||||||
import { OutlinedInput, Paper, Typography } from "@mui/material";
|
import { OutlinedInput, Typography } from "@mui/material";
|
||||||
import Checkbox from "@mui/material/Checkbox";
|
import Checkbox from "@mui/material/Checkbox";
|
||||||
import FormControl from "@mui/material/FormControl";
|
import FormControl from "@mui/material/FormControl";
|
||||||
import FormControlLabel from "@mui/material/FormControlLabel";
|
import FormControlLabel from "@mui/material/FormControlLabel";
|
||||||
import FormGroup from "@mui/material/FormGroup";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import InputAdornment from "@mui/material/InputAdornment";
|
import InputAdornment from "@mui/material/InputAdornment";
|
||||||
import InputLabel from "@mui/material/InputLabel";
|
import InputLabel from "@mui/material/InputLabel";
|
||||||
|
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
|
||||||
import { AppBarBackOnly } from "@/components/appBar/backOnly.jsx";
|
|
||||||
import { AvatarImage } from "@/components/avatar/avatar.jsx";
|
import { AvatarImage } from "@/components/avatar/avatar.jsx";
|
||||||
import "./login.scss";
|
import "./login.scss";
|
||||||
|
|
||||||
import { saveUser } from "@/utils/storage/user";
|
import { saveUser } from "@/utils/storage/user";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { setBackdrop } from "@/utils/store/backdrop.js";
|
import { useBackdropStore } from "@/utils/store/backdrop.js";
|
||||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
import { useMutation } from "@tanstack/react-query";
|
||||||
import React, { useLayoutEffect, useState } from "react";
|
import {
|
||||||
|
createFileRoute,
|
||||||
|
useNavigate,
|
||||||
|
useRouter,
|
||||||
|
} from "@tanstack/react-router";
|
||||||
|
import React, {
|
||||||
|
type ChangeEvent,
|
||||||
|
type FormEvent,
|
||||||
|
useEffect,
|
||||||
|
useState,
|
||||||
|
} from "react";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/login/$userId/$userName")({
|
export const Route = createFileRoute("/_api/login/$userId/$userName")({
|
||||||
component: LoginUser,
|
component: LoginUser,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
type PasswordState = {
|
||||||
|
showpass: boolean;
|
||||||
|
password: string | undefined;
|
||||||
|
};
|
||||||
|
|
||||||
function LoginUser() {
|
function LoginUser() {
|
||||||
const { userName, userId } = Route.useParams();
|
const { userName, userId } = Route.useParams();
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const createApi = useApiInContext((s) => s.createApi);
|
const createApi = useApiInContext((s) => s.createApi);
|
||||||
|
|
||||||
const [password, setPassword] = useState({
|
const [password, setPassword] = useState<PasswordState>({
|
||||||
showpass: false,
|
showpass: false,
|
||||||
|
password: undefined,
|
||||||
});
|
});
|
||||||
const [loading, setLoading] = useState(false);
|
|
||||||
const [rememberMe, setRememberMe] = useState(true);
|
const [rememberMe, setRememberMe] = useState(true);
|
||||||
|
|
||||||
const navigate = useNavigate({ from: "/login/$userId/$userName" });
|
const navigate = useNavigate({ from: "/login/$userId/$userName" });
|
||||||
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
|
||||||
const handlePassword = (prop) => (event) => {
|
const handlePassword =
|
||||||
setPassword({
|
(prop: "password" | "showPassord") =>
|
||||||
...password,
|
(event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
||||||
[prop]: event.target.value,
|
setPassword({
|
||||||
});
|
...password,
|
||||||
};
|
[prop]: event.target.value,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const handleShowPassword = () => {
|
const handleShowPassword = () => {
|
||||||
setPassword({
|
setPassword({
|
||||||
@@ -54,159 +71,139 @@ function LoginUser() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const authUser = async () => {
|
const setBackdrop = useBackdropStore((state) => state.setBackdrop);
|
||||||
try {
|
|
||||||
const auth = await api.authenticateUserByName(
|
|
||||||
userName,
|
|
||||||
password.password,
|
|
||||||
);
|
|
||||||
return auth;
|
|
||||||
} catch (error) {
|
|
||||||
if (error.response?.status === 500) {
|
|
||||||
enqueueSnackbar(
|
|
||||||
"Unable to connect to server. Please try again after some time.",
|
|
||||||
{ variant: "error" },
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
enqueueSnackbar("Incorrect Password.", { variant: "error" });
|
|
||||||
}
|
|
||||||
setLoading(false);
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleLogin = async () => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
if (!api) {
|
||||||
const user = await authUser();
|
return;
|
||||||
sessionStorage.setItem("accessToken", user.data.AccessToken);
|
|
||||||
createApi(api.basePath, user.data.AccessToken);
|
|
||||||
if (rememberMe === true) {
|
|
||||||
await saveUser(userName, user.data.AccessToken);
|
|
||||||
}
|
}
|
||||||
setLoading(false);
|
|
||||||
navigate({ to: "/home" });
|
|
||||||
};
|
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
setBackdrop("", "");
|
setBackdrop("", "");
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleCheckRememberMe = (event) => {
|
const handleCheckRememberMe = (
|
||||||
setRememberMe(event.target.checked);
|
_: ChangeEvent<HTMLInputElement>,
|
||||||
|
checked: boolean,
|
||||||
|
) => {
|
||||||
|
setRememberMe(checked);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleLoginFn = async (event: FormEvent<HTMLFormElement>) => {
|
||||||
|
event.preventDefault();
|
||||||
|
try {
|
||||||
|
if (!api) {
|
||||||
|
throw new Error("API not initialized");
|
||||||
|
}
|
||||||
|
const authenticate = await api.authenticateUserByName(
|
||||||
|
userName,
|
||||||
|
password.password,
|
||||||
|
);
|
||||||
|
if (!authenticate.data.AccessToken) {
|
||||||
|
throw new Error("No access token received");
|
||||||
|
}
|
||||||
|
createApi(api.basePath, authenticate.data?.AccessToken);
|
||||||
|
|
||||||
|
if (rememberMe) await saveUser(userName, authenticate.data.AccessToken);
|
||||||
|
|
||||||
|
router.invalidate().finally(() => {
|
||||||
|
navigate({ to: "/home", replace: true });
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
enqueueSnackbar("Unable to authenticate! Please check your password", {
|
||||||
|
variant: "error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleLogin = useMutation({
|
||||||
|
mutationKey: ["login", "authenticate"],
|
||||||
|
mutationFn: handleLoginFn,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div
|
||||||
<AppBarBackOnly />
|
style={{
|
||||||
<div
|
height: "100vh",
|
||||||
style={{
|
display: "flex",
|
||||||
height: "100vh",
|
justifyContent: "center",
|
||||||
display: "flex",
|
alignItems: "center",
|
||||||
justifyContent: "center",
|
flexDirection: "column",
|
||||||
alignItems: "center",
|
width: "30vw",
|
||||||
flexDirection: "column",
|
margin: "auto",
|
||||||
width: "30vw",
|
}}
|
||||||
margin: "auto",
|
>
|
||||||
}}
|
<AvatarImage userId={userId} />
|
||||||
|
<Typography
|
||||||
|
textAlign="center"
|
||||||
|
variant="h5"
|
||||||
|
sx={{ opacity: 0.8 }}
|
||||||
|
mb={2}
|
||||||
|
mt={2}
|
||||||
>
|
>
|
||||||
<div
|
Login as{" "}
|
||||||
|
<Typography
|
||||||
|
variant="h5"
|
||||||
style={{
|
style={{
|
||||||
marginBottom: "-4em",
|
display: "inline",
|
||||||
boxShadow: "1em 0 hsl(256, 100%, 6%)",
|
|
||||||
}}
|
}}
|
||||||
|
fontWeight={700}
|
||||||
|
className="gradient-text"
|
||||||
>
|
>
|
||||||
<AvatarImage userId={userId} />
|
{userName}
|
||||||
</div>
|
</Typography>
|
||||||
<Paper
|
</Typography>
|
||||||
sx={{
|
<form onSubmit={(e) => handleLogin.mutate(e)}>
|
||||||
|
<FormControl
|
||||||
|
variant="outlined"
|
||||||
|
style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
padding: "1em",
|
|
||||||
paddingTop: "5em",
|
|
||||||
borderRadius: "10px",
|
|
||||||
}}
|
}}
|
||||||
elevation={2}
|
|
||||||
>
|
>
|
||||||
<Typography
|
<InputLabel htmlFor="user-password">Password:</InputLabel>
|
||||||
textAlign="center"
|
<OutlinedInput
|
||||||
variant="h5"
|
id="user-password"
|
||||||
sx={{ opacity: 0.8 }}
|
type={password.showpass ? "text" : "password"}
|
||||||
mb={2}
|
onChange={handlePassword("password")}
|
||||||
>
|
label="Password:"
|
||||||
Login as{" "}
|
endAdornment={
|
||||||
<Typography
|
<InputAdornment position="end">
|
||||||
variant="h5"
|
<IconButton
|
||||||
style={{
|
onClick={handleShowPassword}
|
||||||
display: "inline",
|
aria-label="toggle password visibility"
|
||||||
}}
|
>
|
||||||
fontWeight={700}
|
{password.showpass ? (
|
||||||
className="gradient-text"
|
<span className="material-symbols-rounded">visibility</span>
|
||||||
>
|
) : (
|
||||||
{userName}
|
<span className="material-symbols-rounded">
|
||||||
</Typography>
|
visibility_off
|
||||||
</Typography>
|
</span>
|
||||||
<FormGroup
|
)}
|
||||||
sx={{
|
</IconButton>
|
||||||
width: "100%",
|
</InputAdornment>
|
||||||
}}
|
|
||||||
>
|
|
||||||
<FormControl
|
|
||||||
variant="outlined"
|
|
||||||
style={{
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<InputLabel htmlFor="user-password">Password:</InputLabel>
|
|
||||||
<OutlinedInput
|
|
||||||
id="user-password"
|
|
||||||
type={password.showpass ? "text" : "password"}
|
|
||||||
variant="outlined"
|
|
||||||
onChange={handlePassword("password")}
|
|
||||||
label="Password:"
|
|
||||||
endAdornment={
|
|
||||||
<InputAdornment position="end">
|
|
||||||
<IconButton
|
|
||||||
onClick={handleShowPassword}
|
|
||||||
aria-label="toggle password visibility"
|
|
||||||
>
|
|
||||||
{password.showpass ? (
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
visibility
|
|
||||||
</span>
|
|
||||||
) : (
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
visibility_off
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</IconButton>
|
|
||||||
</InputAdornment>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={rememberMe}
|
|
||||||
onChange={handleCheckRememberMe}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="Remember me"
|
|
||||||
/>
|
|
||||||
</FormGroup>
|
|
||||||
<LoadingButton
|
|
||||||
variant="contained"
|
|
||||||
endIcon={
|
|
||||||
<span className="material-symbols-rounded">chevron_right</span>
|
|
||||||
}
|
}
|
||||||
onClick={handleLogin}
|
/>
|
||||||
loading={loading}
|
</FormControl>
|
||||||
loadingPosition="end"
|
<FormControlLabel
|
||||||
size="large"
|
control={
|
||||||
fullWidth
|
<Checkbox checked={rememberMe} onChange={handleCheckRememberMe} />
|
||||||
>
|
}
|
||||||
Login
|
label="Remember me"
|
||||||
</LoadingButton>
|
/>
|
||||||
</Paper>
|
<LoadingButton
|
||||||
</div>
|
variant="contained"
|
||||||
</>
|
endIcon={
|
||||||
|
<span className="material-symbols-rounded">chevron_right</span>
|
||||||
|
}
|
||||||
|
type="submit"
|
||||||
|
loading={handleLogin.isPending}
|
||||||
|
loadingPosition="end"
|
||||||
|
size="large"
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
Login
|
||||||
|
</LoadingButton>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -74,20 +74,18 @@ function LoginPublicUsersList() {
|
|||||||
}, []);
|
}, []);
|
||||||
if (users.isSuccess) {
|
if (users.isSuccess) {
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="login-container">
|
||||||
<AppBarBackOnly />
|
<Typography variant="h4" align="center">
|
||||||
<div className="login-container">
|
Users
|
||||||
<Typography variant="h4" align="center">
|
</Typography>
|
||||||
Users
|
|
||||||
</Typography>
|
|
||||||
|
|
||||||
<div className="user-list-container roundedScrollbar">
|
<div className="user-list-container roundedScrollbar">
|
||||||
{users.data.map((item) => {
|
{users.data.map((item) => {
|
||||||
return <UserCard user={item} key={item.Id} />;
|
return <UserCard user={item} key={item.Id} />;
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* <div className="buttons">
|
{/* <div className="buttons">
|
||||||
<Button
|
<Button
|
||||||
color="secondary"
|
color="secondary"
|
||||||
variant="contained"
|
variant="contained"
|
||||||
@@ -98,18 +96,17 @@ function LoginPublicUsersList() {
|
|||||||
</Button>
|
</Button>
|
||||||
<QuickConnectButton />
|
<QuickConnectButton />
|
||||||
</div> */}
|
</div> */}
|
||||||
<Chip
|
<Chip
|
||||||
style={{ marginLeft: "50%", transform: "translateX(-50%)" }}
|
style={{ marginLeft: "50%", transform: "translateX(-50%)" }}
|
||||||
label={
|
label={
|
||||||
<Typography variant="body2" align="center">
|
<Typography variant="body2" align="center">
|
||||||
Don't see your user? Try using{" "}
|
Don't see your user? Try using{" "}
|
||||||
<Link to="/login/manual">Manual Login</Link> or{" "}
|
<Link to="/login/manual">Manual Login</Link> or{" "}
|
||||||
<Link to="/setup/server/list">Changing Server</Link>
|
<Link to="/setup/server/list">Changing Server</Link>
|
||||||
</Typography>
|
</Typography>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (users.isError) {
|
if (users.isError) {
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&-form {
|
&-form {
|
||||||
width: 28em;
|
width: 24em;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
background: rgb(255 255 255 / 0.05);
|
background: rgb(255 255 255 / 0.05);
|
||||||
padding: 2em;
|
padding: 2em;
|
||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
border: 1px solid rgb(255 255 255 / 0.1);
|
// border: 1px solid rgb(255 255 255 / 0.1);
|
||||||
&.padded-top {
|
&.padded-top {
|
||||||
margin-top: 25vh;
|
margin-top: 25vh;
|
||||||
}
|
}
|
||||||
|
|||||||
+129
-121
@@ -1,5 +1,10 @@
|
|||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { skipToken, useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import React, { type FormEvent, useLayoutEffect, useState } from "react";
|
import React, {
|
||||||
|
type ChangeEvent,
|
||||||
|
type FormEvent,
|
||||||
|
useEffect,
|
||||||
|
useState,
|
||||||
|
} from "react";
|
||||||
|
|
||||||
import { saveUser } from "@/utils/storage/user.js";
|
import { saveUser } from "@/utils/storage/user.js";
|
||||||
|
|
||||||
@@ -15,19 +20,19 @@ import InputLabel from "@mui/material/InputLabel";
|
|||||||
|
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
|
||||||
import { AppBarBackOnly } from "@/components/appBar/backOnly.jsx";
|
import { useApiInContext } from "@/utils/store/api.js";
|
||||||
import { axiosClient, useApiInContext } from "@/utils/store/api.js";
|
|
||||||
import { getBrandingApi } from "@jellyfin/sdk/lib/utils/api/branding-api";
|
import { getBrandingApi } from "@jellyfin/sdk/lib/utils/api/branding-api";
|
||||||
import "./login.scss";
|
import "./login.scss";
|
||||||
|
|
||||||
import QuickConnectButton from "@/components/buttons/quickConnectButton";
|
import QuickConnectButton from "@/components/buttons/quickConnectButton";
|
||||||
import { setBackdrop } from "@/utils/store/backdrop.js";
|
import { useBackdropStore } from "@/utils/store/backdrop.js";
|
||||||
import { blue } from "@mui/material/colors";
|
import { blue } from "@mui/material/colors";
|
||||||
import {
|
import {
|
||||||
createFileRoute,
|
createFileRoute,
|
||||||
useNavigate,
|
useNavigate,
|
||||||
useRouter,
|
useRouter,
|
||||||
} from "@tanstack/react-router";
|
} from "@tanstack/react-router";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/login/manual")({
|
export const Route = createFileRoute("/_api/login/manual")({
|
||||||
component: UserLoginManual,
|
component: UserLoginManual,
|
||||||
@@ -43,15 +48,15 @@ function UserLoginManual() {
|
|||||||
|
|
||||||
const server = useQuery({
|
const server = useQuery({
|
||||||
queryKey: ["login", "manual", "serverInfo"],
|
queryKey: ["login", "manual", "serverInfo"],
|
||||||
queryFn: async () => {
|
queryFn: async () =>
|
||||||
return (await getBrandingApi(api).getBrandingOptions()).data;
|
api ? (await getBrandingApi(api).getBrandingOptions()).data : skipToken,
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const ssoProviders = useQuery({
|
const ssoProviders = useQuery({
|
||||||
queryKey: ["login", "manual", "ssoProviders"],
|
queryKey: ["login", "manual", "ssoProviders"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
return axiosClient.get(
|
if (!api?.accessToken) return;
|
||||||
|
return axios.get(
|
||||||
`${api.basePath}/sso/SAML/Get?api_key=${api.accessToken}`,
|
`${api.basePath}/sso/SAML/Get?api_key=${api.accessToken}`,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -69,7 +74,7 @@ function UserLoginManual() {
|
|||||||
password: "",
|
password: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
const handlePassword = (prop) => (event) => {
|
const handlePassword = (prop: "password" | "showpass") => (event) => {
|
||||||
setPassword({
|
setPassword({
|
||||||
...password,
|
...password,
|
||||||
[prop]: event.target.value,
|
[prop]: event.target.value,
|
||||||
@@ -86,14 +91,19 @@ function UserLoginManual() {
|
|||||||
const handleLoginFn = async (event: FormEvent<HTMLFormElement>) => {
|
const handleLoginFn = async (event: FormEvent<HTMLFormElement>) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
try {
|
try {
|
||||||
|
if (!api) {
|
||||||
|
throw new Error("Api is not available");
|
||||||
|
}
|
||||||
const authenticate = await api.authenticateUserByName(
|
const authenticate = await api.authenticateUserByName(
|
||||||
username,
|
username,
|
||||||
password.password,
|
password.password,
|
||||||
);
|
);
|
||||||
|
if (!authenticate.data?.AccessToken) {
|
||||||
|
throw new Error("Access token not available");
|
||||||
|
}
|
||||||
createApi(api.basePath, authenticate.data?.AccessToken);
|
createApi(api.basePath, authenticate.data?.AccessToken);
|
||||||
|
|
||||||
if (rememberMe) await saveUser(username, authenticate.data.AccessToken);
|
if (rememberMe) await saveUser(username, authenticate.data.AccessToken);
|
||||||
|
|
||||||
router.invalidate().finally(() => {
|
router.invalidate().finally(() => {
|
||||||
navigate({ to: searchParams.redirect || "/home", replace: true });
|
navigate({ to: searchParams.redirect || "/home", replace: true });
|
||||||
});
|
});
|
||||||
@@ -112,126 +122,124 @@ function UserLoginManual() {
|
|||||||
mutationFn: handleLoginFn,
|
mutationFn: handleLoginFn,
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleCheckRememberMe = (event) => {
|
const handleCheckRememberMe = (
|
||||||
setRememberMe(event.target.checked);
|
_: ChangeEvent<HTMLInputElement>,
|
||||||
|
checked: boolean,
|
||||||
|
) => {
|
||||||
|
setRememberMe(checked);
|
||||||
};
|
};
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
const setBackdrop = useBackdropStore((state) => state.setBackdrop);
|
||||||
|
useEffect(() => {
|
||||||
setBackdrop("", "");
|
setBackdrop("", "");
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="login scrollY">
|
||||||
<AppBarBackOnly />
|
<div
|
||||||
<div className="login scrollY">
|
className={`login-form-container ${
|
||||||
<div
|
server.data?.LoginDisclaimer && "padded-top"
|
||||||
className={`login-form-container ${
|
}`}
|
||||||
server.data?.LoginDisclaimer && "padded-top"
|
>
|
||||||
}`}
|
<Typography variant="h4" color="textPrimary">
|
||||||
>
|
Login
|
||||||
<Typography variant="h3" color="textPrimary">
|
</Typography>
|
||||||
Login
|
<form className="login-form" onSubmit={(e) => handleLogin.mutate(e)}>
|
||||||
</Typography>
|
<TextField
|
||||||
<form className="login-form" onSubmit={(e) => handleLogin.mutate(e)}>
|
variant="outlined"
|
||||||
<TextField
|
label="Username"
|
||||||
variant="outlined"
|
onChange={(e) => setUsername(e.currentTarget.value)}
|
||||||
label="Username"
|
/>
|
||||||
onChange={(e) => setUsername(e.currentTarget.value)}
|
<FormControl sx={{ width: "100%" }} variant="outlined">
|
||||||
/>
|
<InputLabel htmlFor="user-password">Password:</InputLabel>
|
||||||
<FormControl sx={{ width: "100%" }} variant="outlined">
|
<OutlinedInput
|
||||||
<InputLabel htmlFor="user-password">Password:</InputLabel>
|
fullWidth
|
||||||
<OutlinedInput
|
id="user-password"
|
||||||
fullWidth
|
type={password.showpass ? "text" : "password"}
|
||||||
id="user-password"
|
onChange={handlePassword("password")}
|
||||||
type={password.showpass ? "text" : "password"}
|
label="Password:"
|
||||||
onChange={handlePassword("password")}
|
endAdornment={
|
||||||
label="Password:"
|
<InputAdornment position="end">
|
||||||
endAdornment={
|
<IconButton
|
||||||
<InputAdornment position="end">
|
onClick={handleShowPassword}
|
||||||
<IconButton
|
aria-label="toggle password visibility"
|
||||||
onClick={handleShowPassword}
|
>
|
||||||
aria-label="toggle password visibility"
|
{password.showpass ? (
|
||||||
>
|
<span className="material-symbols-rounded">
|
||||||
{password.showpass ? (
|
visibility
|
||||||
<span className="material-symbols-rounded">
|
</span>
|
||||||
visibility
|
) : (
|
||||||
</span>
|
<span className="material-symbols-rounded">
|
||||||
) : (
|
visibility_off
|
||||||
<span className="material-symbols-rounded">
|
</span>
|
||||||
visibility_off
|
)}
|
||||||
</span>
|
</IconButton>
|
||||||
)}
|
</InputAdornment>
|
||||||
</IconButton>
|
|
||||||
</InputAdornment>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={rememberMe}
|
|
||||||
onChange={handleCheckRememberMe}
|
|
||||||
/>
|
|
||||||
}
|
}
|
||||||
label="Remember me"
|
|
||||||
/>
|
/>
|
||||||
<div
|
</FormControl>
|
||||||
className="flex flex-row"
|
<FormControlLabel
|
||||||
style={{ width: "100%", gap: "0.8em", flexWrap: "wrap" }}
|
control={
|
||||||
>
|
<Checkbox checked={rememberMe} onChange={handleCheckRememberMe} />
|
||||||
<LoadingButton
|
}
|
||||||
variant="contained"
|
label="Remember me"
|
||||||
type="submit"
|
/>
|
||||||
loading={handleLogin.isPending}
|
<div
|
||||||
sx={{ width: "100%" }}
|
className="flex flex-row"
|
||||||
>
|
style={{ width: "100%", gap: "0.8em", flexWrap: "wrap" }}
|
||||||
Login
|
|
||||||
</LoadingButton>
|
|
||||||
<QuickConnectButton />
|
|
||||||
<Button
|
|
||||||
color="secondary"
|
|
||||||
variant="contained"
|
|
||||||
className="userEventButton"
|
|
||||||
// size="large"
|
|
||||||
style={{ flex: 1 }}
|
|
||||||
onClick={() => navigate({ to: "/setup/server/list" })}
|
|
||||||
>
|
|
||||||
Change Server
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
{server.isSuccess && server.data.LoginDisclaimer && (
|
|
||||||
<Paper
|
|
||||||
elevation={5}
|
|
||||||
style={{
|
|
||||||
marginTop: "1em",
|
|
||||||
padding: "1em",
|
|
||||||
borderRadius: "15px",
|
|
||||||
width: "32em",
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<div
|
<LoadingButton
|
||||||
className="flex flex-row flex-align-center"
|
variant="contained"
|
||||||
style={{ gap: "0.5em", marginBottom: "0.5em" }}
|
type="submit"
|
||||||
|
loading={handleLogin.isPending}
|
||||||
|
sx={{ width: "100%" }}
|
||||||
>
|
>
|
||||||
<span
|
Login
|
||||||
className="material-symbols-rounded"
|
</LoadingButton>
|
||||||
style={{
|
<Button
|
||||||
color: blue[700],
|
color="secondary"
|
||||||
"--fill": 1,
|
variant="contained"
|
||||||
}}
|
className="userEventButton"
|
||||||
>
|
// size="large"
|
||||||
info
|
style={{ flex: 1 }}
|
||||||
</span>
|
onClick={() => navigate({ to: "/setup/server/list" })}
|
||||||
Notice
|
>
|
||||||
</div>
|
Change Server
|
||||||
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
</Button>
|
||||||
{server.data.LoginDisclaimer}
|
</div>
|
||||||
</Typography>
|
</form>
|
||||||
</Paper>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
{server.isSuccess && server.data.LoginDisclaimer && (
|
||||||
|
<Paper
|
||||||
|
elevation={5}
|
||||||
|
style={{
|
||||||
|
marginTop: "1em",
|
||||||
|
padding: "1em",
|
||||||
|
borderRadius: "15px",
|
||||||
|
width: "32em",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="flex flex-row flex-align-center"
|
||||||
|
style={{ gap: "0.5em", marginBottom: "0.5em" }}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded"
|
||||||
|
style={{
|
||||||
|
color: blue[700],
|
||||||
|
//@ts-ignore
|
||||||
|
"--fill": 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
info
|
||||||
|
</span>
|
||||||
|
Notice
|
||||||
|
</div>
|
||||||
|
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
||||||
|
{server.data.LoginDisclaimer}
|
||||||
|
</Typography>
|
||||||
|
</Paper>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user