mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2026-01-04 21:58:39 -05:00
feat: revamp login page and support disabling media server login (#1286)
* 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
This commit is contained in:
37
src/hooks/usePlexLogin.ts
Normal file
37
src/hooks/usePlexLogin.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user