Skip to content
This repository has been archived by the owner on Sep 22, 2024. It is now read-only.

Commit

Permalink
feat(plugins/auth): add logo to auth-form
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelrk committed May 21, 2024
1 parent d71a06b commit 1b9b1e6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/plugins/auth/islands/auth-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function AuthForm(props: AuthFormProps) {
const url = new URL(props.request.url);
const error = url.searchParams.get("error");

const { title, description, providers } = props.config;
const { logo, title, description, providers } = props.config;

const hasEmail = !!providers?.email;
const hasOAuth2 = Object.entries(providers ?? {}).some(
Expand All @@ -35,6 +35,9 @@ export function AuthForm(props: AuthFormProps) {
return (
<>
<div className="flex flex-col space-y-2 text-center">
{logo && (
<img src={logo} alt="Logo" className="mx-auto mb-4 w-16 h-16" />
)}
{title && (
<h1 className="text-2xl font-semibold">
{title}
Expand Down
3 changes: 3 additions & 0 deletions lib/plugins/auth/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import type { Auth, AuthProvider, AuthUser } from "./utils/types.ts";
export * from "../../deps/deno_kv_oauth/mod.ts";

export type AuthConfig = {
/** An image URL for the logo to appear above the login form at /auth. */
logo?: string;
/** A short title for the app to appear above the login form at /auth. */
title?: string;
/** A short description for the app to appear above the login form at /auth. */
Expand Down Expand Up @@ -78,6 +80,7 @@ export const auth = (config: AuthConfig): Plugin<NetzoState> => {
].some((key) => !!config?.providers?.[key as AuthProvider]);
if (!authEnabled) return { name: "netzo.auth" }; // skip if auth but no providers are set

config.logo ??= "";
config.title ??= "Sign In";
config.description ??= "Sign in to access the app";
config.caption ??= ""; // e.g. 'By signing in you agree to the <a href="/" target="_blank">Terms of Service</a>';
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/auth/routes/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const config: RouteConfig = {

export default (config: AuthConfig) => {
return defineRoute((req, ctx) => {
const authFormWrapper = "grid gap-6 w-full xs:w-[350px] max-w-[350px]";
const authFormWrapper = "grid gap-6 w-full xs:w-[350px] max-w-[350px] pb-16";
if (config.image) {
return (
<div className="w-full h-full lg:grid lg:min-h-[600px] lg:grid-cols-2 xl:min-h-[800px]">
Expand Down

0 comments on commit 1b9b1e6

Please sign in to comment.