diff --git a/Foxnouns.Backend/Controllers/Authentication/AuthController.cs b/Foxnouns.Backend/Controllers/Authentication/AuthController.cs index 1a737eb..53aa171 100644 --- a/Foxnouns.Backend/Controllers/Authentication/AuthController.cs +++ b/Foxnouns.Backend/Controllers/Authentication/AuthController.cs @@ -39,10 +39,10 @@ public class AuthController( + $"&prompt=none&state={state}" + $"&redirect_uri={HttpUtility.UrlEncode($"{config.BaseUrl}/auth/callback/discord")}"; - return Ok(new UrlsResponse(config.EmailAuth.Enabled, discord, null, null)); + return Ok(new UrlsResponse(discord, null, null)); } - private record UrlsResponse(bool EmailEnabled, string? Discord, string? Google, string? Tumblr); + private record UrlsResponse(string? Discord, string? Google, string? Tumblr); public record AuthResponse( UserRendererService.UserResponse User, diff --git a/Foxnouns.Backend/Controllers/Authentication/EmailAuthController.cs b/Foxnouns.Backend/Controllers/Authentication/EmailAuthController.cs index 7e3706e..937ab3a 100644 --- a/Foxnouns.Backend/Controllers/Authentication/EmailAuthController.cs +++ b/Foxnouns.Backend/Controllers/Authentication/EmailAuthController.cs @@ -100,8 +100,6 @@ public class EmailAuthController( [FromBody] CompleteRegistrationRequest req ) { - CheckRequirements(); - var email = await keyCacheService.GetKeyAsync($"email:{req.Ticket}"); if (email == null) throw new ApiError.BadRequest("Unknown ticket", "ticket", req.Ticket); @@ -187,8 +185,6 @@ public class EmailAuthController( [Authorize("*")] public async Task AddEmailAddressAsync([FromBody] AddEmailAddressRequest req) { - CheckRequirements(); - var emails = await db .AuthMethods.Where(m => m.UserId == CurrentUser!.Id && m.AuthType == AuthType.Email) .ToListAsync(); diff --git a/Foxnouns.Frontend/app/lib/api/auth.ts b/Foxnouns.Frontend/app/lib/api/auth.ts index 0f8ce27..a0d5bf1 100644 --- a/Foxnouns.Frontend/app/lib/api/auth.ts +++ b/Foxnouns.Frontend/app/lib/api/auth.ts @@ -16,7 +16,6 @@ export type CallbackResponse = { }; export type AuthUrls = { - email_enabled: boolean; discord?: string; google?: string; tumblr?: string; diff --git a/Foxnouns.Frontend/app/lib/request.server.ts b/Foxnouns.Frontend/app/lib/request.server.ts index 7da3e84..562666d 100644 --- a/Foxnouns.Frontend/app/lib/request.server.ts +++ b/Foxnouns.Frontend/app/lib/request.server.ts @@ -1,5 +1,5 @@ import { parse as parseCookie, serialize as serializeCookie } from "cookie"; -import { INTERNAL_API_BASE } from "~/env.server"; +import { API_BASE, INTERNAL_API_BASE } from "~/env.server"; import { ApiError, ErrorCode } from "./api/error"; import { tokenCookieName } from "~/lib/utils"; @@ -16,7 +16,7 @@ export async function baseRequest( path: string, params: RequestParams = {}, ): Promise { - const base = params.isInternal ? INTERNAL_API_BASE + "/internal" : INTERNAL_API_BASE + "/v2"; + const base = params.isInternal ? INTERNAL_API_BASE + "/internal" : API_BASE + "/v2"; const url = `${base}${path}`; const resp = await fetch(url, { diff --git a/Foxnouns.Frontend/app/routes/auth.log-in/route.tsx b/Foxnouns.Frontend/app/routes/auth.log-in/route.tsx index aaffd80..eadbaa9 100644 --- a/Foxnouns.Frontend/app/routes/auth.log-in/route.tsx +++ b/Foxnouns.Frontend/app/routes/auth.log-in/route.tsx @@ -11,7 +11,7 @@ import { useActionData, useLoaderData, } from "@remix-run/react"; -import { Form, Button, ButtonGroup, ListGroup } from "react-bootstrap"; +import { Form, Button, ButtonGroup, ListGroup, Row, Col } from "react-bootstrap"; import { useTranslation } from "react-i18next"; import i18n from "~/i18next.server"; import serverRequest, { getToken, writeCookie } from "~/lib/request.server"; @@ -78,36 +78,33 @@ export default function LoginPage() { return ( <> -
- {!urls.email_enabled &&
} - {urls.email_enabled && ( -
-

{t("log-in.form-title")}

- {actionData?.error && } - -
- - {t("log-in.email")} - - - - {t("log-in.password")} - - + + +

{t("log-in.form-title")}

+ {actionData?.error && } + + + + {t("log-in.email")} + + + + {t("log-in.password")} + + - - - - - - -
- )} -
+ + + + + + + +

{t("log-in.3rd-party.title")}

{t("log-in.3rd-party.desc")}

@@ -127,9 +124,8 @@ export default function LoginPage() { )} -
- {!urls.email_enabled &&
} -
+ + ); } diff --git a/Foxnouns.Frontend/app/routes/settings._index/route.tsx b/Foxnouns.Frontend/app/routes/settings._index/route.tsx index 88655fc..5b90851 100644 --- a/Foxnouns.Frontend/app/routes/settings._index/route.tsx +++ b/Foxnouns.Frontend/app/routes/settings._index/route.tsx @@ -1,13 +1,6 @@ import { Button, Form, InputGroup, Table } from "react-bootstrap"; import { useTranslation } from "react-i18next"; -import { - Form as RemixForm, - Link, - Outlet, - useActionData, - useFetcher, - useRouteLoaderData, -} from "@remix-run/react"; +import { Form as RemixForm, useActionData, useFetcher, useRouteLoaderData } from "@remix-run/react"; import { loader as settingsLoader } from "../settings/route"; import { loader as rootLoader } from "../../root"; import { DateTime } from "luxon"; @@ -50,12 +43,12 @@ export default function SettingsIndex() { const actionData = useActionData(); const { meta } = useRouteLoaderData("root")!; const { t } = useTranslation(); + const fetcher = useFetcher(); const createdAt = idTimestamp(user.id); return ( <> -
@@ -88,10 +81,11 @@ export default function SettingsIndex() {

{t("settings.general.log-out-everywhere")}

{t("settings.general.log-out-everywhere-hint")}

- {/* @ts-expect-error as=Link */} - + + +

{t("settings.general.table-header")}

diff --git a/Foxnouns.Frontend/app/routes/settings.auth/route.tsx b/Foxnouns.Frontend/app/routes/settings.auth/route.tsx index 125f413..22d2fcd 100644 --- a/Foxnouns.Frontend/app/routes/settings.auth/route.tsx +++ b/Foxnouns.Frontend/app/routes/settings.auth/route.tsx @@ -1,12 +1,10 @@ import i18n from "~/i18next.server"; import { LoaderFunctionArgs, MetaFunction } from "@remix-run/node"; -import { Link, useLoaderData, useRouteLoaderData } from "@remix-run/react"; +import { Link, useRouteLoaderData } from "@remix-run/react"; import { Button, ListGroup } from "react-bootstrap"; import { loader as settingsLoader } from "~/routes/settings/route"; import { useTranslation } from "react-i18next"; import { AuthMethod, MeUser } from "~/lib/api/user"; -import serverRequest from "~/lib/request.server"; -import { AuthUrls } from "~/lib/api/auth"; export const meta: MetaFunction = ({ data }) => { return [{ title: `${data?.meta.title || "Authentication"} • pronouns.cc` }]; @@ -14,16 +12,17 @@ export const meta: MetaFunction = ({ data }) => { export const loader = async ({ request }: LoaderFunctionArgs) => { const t = await i18n.getFixedT(request); - const urls = await serverRequest("POST", "/auth/urls", { isInternal: true }); - - return { urls, meta: { title: t("settings.auth.title") } }; + return { meta: { title: t("settings.auth.title") } }; }; export default function AuthSettings() { - const { urls } = useLoaderData(); const { user } = useRouteLoaderData("routes/settings")!; - return
{urls.email_enabled && }
; + return ( +
+ +
+ ); } function EmailSettings({ user }: { user: MeUser }) { @@ -45,7 +44,7 @@ function EmailSettings({ user }: { user: MeUser }) { )} {emails.length < 3 && (

- {/* @ts-expect-error as=Link */} + {/* @ts-expect-error using as=Link causes an error here, even though it runs completely fine */} - {/* @ts-expect-error as=Link */} - - - - - ); -} diff --git a/Foxnouns.Frontend/app/routes/settings/route.tsx b/Foxnouns.Frontend/app/routes/settings/route.tsx index 9d8247a..3ef35fd 100644 --- a/Foxnouns.Frontend/app/routes/settings/route.tsx +++ b/Foxnouns.Frontend/app/routes/settings/route.tsx @@ -30,35 +30,30 @@ export default function SettingsLayout() { const { t } = useTranslation(); const { pathname } = useLocation(); - const isActive = (matches: string[] | string, startsWith: boolean = false) => - startsWith - ? typeof matches === "string" - ? pathname.startsWith(matches) - : matches.some((m) => pathname.startsWith(m)) - : typeof matches === "string" - ? matches === pathname - : matches.includes(pathname); - return ( <>

diff --git a/Foxnouns.Frontend/public/locales/en.json b/Foxnouns.Frontend/public/locales/en.json index c834e95..5a25098 100644 --- a/Foxnouns.Frontend/public/locales/en.json +++ b/Foxnouns.Frontend/public/locales/en.json @@ -105,8 +105,7 @@ "member-list-hidden": "Member list hidden?", "custom-preferences": "Custom preferences", "role": "Account role", - "username-update-error": "Could not update your username as the new username is invalid:\n{{message}}", - "log-out-everywhere-confirm": "Are you sure you want to log out everywhere?\nPlease double check your authentication methods before doing so, as it might lock you out of your account." + "username-update-error": "Could not update your username as the new username is invalid:\n{{message}}" }, "auth": { "title": "Authentication",