diff --git a/back/tests/Kyoo.Tests/Database/RepositoryActivator.cs b/back/tests/Kyoo.Tests/Database/RepositoryActivator.cs index 1d741234..af83d7ae 100644 --- a/back/tests/Kyoo.Tests/Database/RepositoryActivator.cs +++ b/back/tests/Kyoo.Tests/Database/RepositoryActivator.cs @@ -59,7 +59,7 @@ namespace Kyoo.Tests.Database SeasonRepository season = new(_NewContext(), thumbs.Object); LibraryItemRepository libraryItem = new(_NewConnection(), new(null)); EpisodeRepository episode = new(_NewContext(), show, thumbs.Object); - UserRepository user = new(_NewContext(), thumbs.Object); + UserRepository user = new(_NewContext(), _NewConnection(), new(null), thumbs.Object); _repositories = new IBaseRepository[] { diff --git a/front/apps/mobile/app/(app)/_layout.tsx b/front/apps/mobile/app/(app)/_layout.tsx index fd46a357..f34f1b38 100644 --- a/front/apps/mobile/app/(app)/_layout.tsx +++ b/front/apps/mobile/app/(app)/_layout.tsx @@ -35,7 +35,7 @@ export default function SignGuard() { const netInfo = useNetInfo(); if (error && netInfo.isConnected) return ; - if (!account) return ; + if (!account) return ; return ( . + */ + +import { ServerUrlPage } from "@kyoo/ui"; + +export default ServerUrlPage; diff --git a/front/packages/ui/src/index.ts b/front/packages/ui/src/index.ts index e1823fca..17d088e7 100644 --- a/front/packages/ui/src/index.ts +++ b/front/packages/ui/src/index.ts @@ -25,7 +25,7 @@ export { MovieDetails, ShowDetails } from "./details"; export { CollectionPage } from "./collection"; export { Player } from "./player"; export { SearchPage } from "./search"; -export { LoginPage, RegisterPage, OidcCallbackPage } from "./login"; +export { ServerUrlPage, LoginPage, RegisterPage, OidcCallbackPage } from "./login"; export { DownloadPage, DownloadProvider } from "./downloads"; export { SettingsPage } from "./settings"; export { AdminPage } from "./admin"; diff --git a/front/packages/ui/src/login/index.ts b/front/packages/ui/src/login/index.ts index c4cfd5ea..da4c05a7 100644 --- a/front/packages/ui/src/login/index.ts +++ b/front/packages/ui/src/login/index.ts @@ -20,4 +20,5 @@ export { LoginPage } from "./login"; export { RegisterPage } from "./register"; +export { ServerUrlPage } from "./server-url"; export { OidcCallbackPage } from "./oidc"; diff --git a/front/packages/ui/src/login/login.tsx b/front/packages/ui/src/login/login.tsx index 2a2a8fba..2ea36b29 100644 --- a/front/packages/ui/src/login/login.tsx +++ b/front/packages/ui/src/login/login.tsx @@ -31,15 +31,7 @@ import { FormPage } from "./form"; import { PasswordInput } from "./password-input"; import { OidcLogin } from "./oidc"; -export const cleanApiUrl = (apiUrl: string) => { - if (Platform.OS === "web") return undefined; - if (!/https?:\/\//.test(apiUrl)) apiUrl = "http://" + apiUrl; - apiUrl = apiUrl.replace(/\/$/, ""); - return apiUrl + "/api"; -}; - export const LoginPage: QueryPage<{ error?: string }> = ({ error: initialError }) => { - const [apiUrl, setApiUrl] = useState(""); const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(initialError); @@ -49,19 +41,9 @@ export const LoginPage: QueryPage<{ error?: string }> = ({ error: initialError } const { css } = useYoshiki(); return ( - +

{t("login.login")}

- {Platform.OS !== "web" && ( - <> -

{t("login.server")}

- - - )}

{t("login.username")}

setUsername(value)} />

{t("login.password")}

diff --git a/front/packages/ui/src/login/oidc.tsx b/front/packages/ui/src/login/oidc.tsx index 7caad26e..ac297413 100644 --- a/front/packages/ui/src/login/oidc.tsx +++ b/front/packages/ui/src/login/oidc.tsx @@ -19,7 +19,6 @@ */ import { - KyooErrors, QueryIdentifier, QueryPage, ServerInfo, @@ -31,7 +30,7 @@ import { Button, HR, P, Skeleton, ts } from "@kyoo/primitives"; import { View, ImageBackground } from "react-native"; import { percent, rem, useYoshiki } from "yoshiki/native"; import { useTranslation } from "react-i18next"; -import { useEffect, useRef, useState } from "react"; +import { useEffect, useRef } from "react"; import { useRouter } from "solito/router"; import { ErrorView } from "../errors"; diff --git a/front/packages/ui/src/login/register.tsx b/front/packages/ui/src/login/register.tsx index 4fe3f27c..6a6ada61 100644 --- a/front/packages/ui/src/login/register.tsx +++ b/front/packages/ui/src/login/register.tsx @@ -29,11 +29,9 @@ import { percent, px, useYoshiki } from "yoshiki/native"; import { DefaultLayout } from "../layout"; import { FormPage } from "./form"; import { PasswordInput } from "./password-input"; -import { cleanApiUrl } from "./login"; import { OidcLogin } from "./oidc"; export const RegisterPage: QueryPage = () => { - const [apiUrl, setApiUrl] = useState(""); const [email, setEmail] = useState(""); const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); @@ -86,7 +84,6 @@ export const RegisterPage: QueryPage = () => { const { error } = await login( "register", { email, username, password, apiUrl: cleanApiUrl(apiUrl) }, - 5_000, ); setError(error); if (error) return; diff --git a/front/packages/ui/src/login/server-url.tsx b/front/packages/ui/src/login/server-url.tsx new file mode 100644 index 00000000..0a932fd2 --- /dev/null +++ b/front/packages/ui/src/login/server-url.tsx @@ -0,0 +1,101 @@ +/* + * Kyoo - A portable and vast media library solution. + * Copyright (c) Kyoo. + * + * See AUTHORS.md and LICENSE file in the project root for full license information. + * + * Kyoo is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * Kyoo is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Kyoo. If not, see . + */ + +import { QueryIdentifier, QueryPage, ServerInfo, ServerInfoP, useFetch } from "@kyoo/models"; +import { Button, P, Input, ts, H1, HR } from "@kyoo/primitives"; +import { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { Platform, View } from "react-native"; +import { useRouter } from "solito/router"; +import { Theme, useYoshiki } from "yoshiki/native"; +import { DefaultLayout } from "../layout"; + +export const cleanApiUrl = (apiUrl: string) => { + if (Platform.OS === "web") return undefined; + if (!/https?:\/\//.test(apiUrl)) apiUrl = "http://" + apiUrl; + apiUrl = apiUrl.replace(/\/$/, ""); + return apiUrl + "/api"; +}; + +const query: QueryIdentifier = { + path: ["info"], + parser: ServerInfoP, +}; + +export const ServerUrlPage: QueryPage = () => { + const [apiUrl, setApiUrl] = useState(""); + const { data, error } = useFetch(query); + const router = useRouter(); + const { t } = useTranslation(); + const { css } = useYoshiki(); + + return ( + +

{t("login.server")}

+ + + {error && ( +

theme.colors.red, alignSelf: "center" })}> + {error.errors[0]} +

+ )} +
+ +