mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2026-01-01 20:28:40 -05:00
* feat: support disabling jellyfin login * feat: revamp login screen Update the login screen for better usability, especially with OpenID Connect and Plex login, allowing one-click login and removing the accordion layout. Additionally, ensures that media server login is hidden when disabled in the settings. * test: update cypress login command
38 lines
751 B
TypeScript
38 lines
751 B
TypeScript
import PlexOAuth from '@app/utils/plex';
|
|
import { useState } from 'react';
|
|
|
|
const plexOAuth = new PlexOAuth();
|
|
|
|
function usePlexLogin({
|
|
onAuthToken,
|
|
onError,
|
|
}: {
|
|
onAuthToken: (authToken: string) => void;
|
|
onError?: (err: string) => void;
|
|
}) {
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const getPlexLogin = async () => {
|
|
setLoading(true);
|
|
try {
|
|
const authToken = await plexOAuth.login();
|
|
setLoading(false);
|
|
onAuthToken(authToken);
|
|
} catch (e) {
|
|
if (onError) {
|
|
onError(e.message);
|
|
}
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
const login = () => {
|
|
plexOAuth.preparePopup();
|
|
setTimeout(() => getPlexLogin(), 1500);
|
|
};
|
|
|
|
return { loading, login };
|
|
}
|
|
|
|
export default usePlexLogin;
|