Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove auth methods besides Stanford SSO #76

Merged
merged 5 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ VITE_PUBLIC_FIREBASE_PROJECT_ID=
VITE_PUBLIC_FIREBASE_STORAGE_BUCKET=
VITE_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=
VITE_PUBLIC_FIREBASE_APP_ID=
VITE_PUBLIC_EMULATOR=
VITE_PUBLIC_EMAIL_PASSWORD_SIGN_IN=""
```

3. Start the Vite Application
Expand Down
18 changes: 14 additions & 4 deletions env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
import { createEnv } from '@t3-oss/env-core'
import { z } from 'zod'

const booleanFlag = z
.preprocess((value) => {
if (typeof value === 'string') {
const flag = value.trim().toLowerCase()
return flag === 'true' || flag === '1' || flag === 't'
}
return value
}, z.boolean().optional())
.default(false)

Check warning on line 19 in env.ts

View check run for this annotation

Codecov / codecov/patch

env.ts#L11-L19

Added lines #L11 - L19 were not covered by tests

export const env = createEnv({
server: {},
client: {
Expand All @@ -17,10 +27,8 @@
VITE_PUBLIC_FIREBASE_STORAGE_BUCKET: z.string().min(1),
VITE_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: z.string().min(1),
VITE_PUBLIC_FIREBASE_APP_ID: z.string().min(1),
VITE_PUBLIC_EMULATOR: z.preprocess((value) => {
if (typeof value === 'string') return value === 'true'
return value
}, z.boolean().optional()),
VITE_PUBLIC_EMULATOR: booleanFlag,
VITE_PUBLIC_EMAIL_PASSWORD_SIGN_IN: booleanFlag,

Check warning on line 31 in env.ts

View check run for this annotation

Codecov / codecov/patch

env.ts#L30-L31

Added lines #L30 - L31 were not covered by tests
},
clientPrefix: 'VITE_PUBLIC',
runtimeEnv: {
Expand All @@ -35,5 +43,7 @@
.VITE_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
VITE_PUBLIC_FIREBASE_APP_ID: import.meta.env.VITE_PUBLIC_FIREBASE_APP_ID,
VITE_PUBLIC_EMULATOR: import.meta.env.VITE_PUBLIC_EMULATOR,
VITE_PUBLIC_EMAIL_PASSWORD_SIGN_IN: import.meta.env
.VITE_PUBLIC_EMAIL_PASSWORD_SIGN_IN,

Check warning on line 47 in env.ts

View check run for this annotation

Codecov / codecov/patch

env.ts#L46-L47

Added lines #L46 - L47 were not covered by tests
},
})
1 change: 1 addition & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ declare global {
VITE_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: string
VITE_PUBLIC_FIREBASE_APP_ID: string
VITE_PUBLIC_EMULATOR: string
VITE_PUBLIC_EMAIL_PASSWORD_SIGN_IN: string
}
}
1 change: 0 additions & 1 deletion modules/firebase/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ if (enableEmulation)

export const authProvider = {
stanford: new OAuthProvider('oidc.stanford'),
apple: new OAuthProvider('apple.com'),
}

export const db = getFirestore(firebaseApp)
Expand Down
9 changes: 9 additions & 0 deletions routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,47 +38,56 @@
} as any)

const SignInIndexRoute = SignInIndexImport.update({
id: '/sign-in/',

Check warning on line 41 in routeTree.gen.ts

View check run for this annotation

Codecov / codecov/patch

routeTree.gen.ts#L41

Added line #L41 was not covered by tests
path: '/sign-in/',
getParentRoute: () => rootRoute,
} as any)

const DashboardIndexRoute = DashboardIndexImport.update({
id: '/',

Check warning on line 47 in routeTree.gen.ts

View check run for this annotation

Codecov / codecov/patch

routeTree.gen.ts#L47

Added line #L47 was not covered by tests
path: '/',
getParentRoute: () => DashboardRoute,
} as any)

const DashboardUsersInviteRoute = DashboardUsersInviteImport.update({
id: '/users/invite',

Check warning on line 53 in routeTree.gen.ts

View check run for this annotation

Codecov / codecov/patch

routeTree.gen.ts#L53

Added line #L53 was not covered by tests
path: '/users/invite',
getParentRoute: () => DashboardRoute,
} as any)

const DashboardUsersIdRoute = DashboardUsersIdImport.update({
id: '/users/$id',

Check warning on line 59 in routeTree.gen.ts

View check run for this annotation

Codecov / codecov/patch

routeTree.gen.ts#L59

Added line #L59 was not covered by tests
path: '/users/$id',
getParentRoute: () => DashboardRoute,
} as any)

const DashboardPatientsInviteRoute = DashboardPatientsInviteImport.update({
id: '/patients/invite',

Check warning on line 65 in routeTree.gen.ts

View check run for this annotation

Codecov / codecov/patch

routeTree.gen.ts#L65

Added line #L65 was not covered by tests
path: '/patients/invite',
getParentRoute: () => DashboardRoute,
} as any)

const DashboardUsersIndexRoute = DashboardUsersIndexImport.update({
id: '/users/',

Check warning on line 71 in routeTree.gen.ts

View check run for this annotation

Codecov / codecov/patch

routeTree.gen.ts#L71

Added line #L71 was not covered by tests
path: '/users/',
getParentRoute: () => DashboardRoute,
} as any)

const DashboardPatientsIndexRoute = DashboardPatientsIndexImport.update({
id: '/patients/',

Check warning on line 77 in routeTree.gen.ts

View check run for this annotation

Codecov / codecov/patch

routeTree.gen.ts#L77

Added line #L77 was not covered by tests
path: '/patients/',
getParentRoute: () => DashboardRoute,
} as any)

const DashboardNotificationsIndexRoute =
DashboardNotificationsIndexImport.update({
id: '/notifications/',

Check warning on line 84 in routeTree.gen.ts

View check run for this annotation

Codecov / codecov/patch

routeTree.gen.ts#L84

Added line #L84 was not covered by tests
path: '/notifications/',
getParentRoute: () => DashboardRoute,
} as any)

const DashboardPatientsIdIndexRoute = DashboardPatientsIdIndexImport.update({
id: '/patients/$id/',

Check warning on line 90 in routeTree.gen.ts

View check run for this annotation

Codecov / codecov/patch

routeTree.gen.ts#L90

Added line #L90 was not covered by tests
path: '/patients/$id/',
getParentRoute: () => DashboardRoute,
} as any)
Expand Down
8 changes: 3 additions & 5 deletions routes/~sign-in/~index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { signInWithEmailAndPassword, signInWithPopup } from 'firebase/auth'
import { Helmet } from 'react-helmet'
import { AsideEngageLayout } from '@/components/AsideEngageLayout'
import { env } from '@/env'

Check warning on line 12 in routes/~sign-in/~index.tsx

View check run for this annotation

Codecov / codecov/patch

routes/~sign-in/~index.tsx#L12

Added line #L12 was not covered by tests
import { authProvider, auth } from '@/modules/firebase/app'
import { SignInForm as AuthSignInForm } from '@/packages/design-system/src/modules/auth/SignInForm'

Expand All @@ -19,11 +20,8 @@
</Helmet>
<AuthSignInForm
className="mx-auto w-[350px]"
providers={[
{ name: 'Apple', provider: authProvider.apple },
{ name: 'Stanford', provider: authProvider.stanford },
]}
enableEmailPassword
providers={[{ name: 'Stanford', provider: authProvider.stanford }]}
enableEmailPassword={env.VITE_PUBLIC_EMAIL_PASSWORD_SIGN_IN}

Check warning on line 24 in routes/~sign-in/~index.tsx

View check run for this annotation

Codecov / codecov/patch

routes/~sign-in/~index.tsx#L23-L24

Added lines #L23 - L24 were not covered by tests
auth={auth}
signInWithPopup={signInWithPopup}
signInWithEmailAndPassword={signInWithEmailAndPassword}
Expand Down
1 change: 1 addition & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type ImportMetaEnv = {
VITE_PUBLIC_FIREBASE_PROJECT_ID: string
VITE_PUBLIC_FIREBASE_STORAGE_BUCKET: string
VITE_PUBLIC_EMULATOR: string
VITE_PUBLIC_EMAIL_PASSWORD_SIGN_IN: string
BASE_URL: string
MODE: string
DEV: boolean
Expand Down
Loading