-
Notifications
You must be signed in to change notification settings - Fork 5
/
auth.ts
28 lines (25 loc) · 861 Bytes
/
auth.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { createAuthentication } from '@redwoodjs/auth'
import {
createLocalAuthImplementation,
localAuthClient,
} from 'src/auth/localAuth'
import {
createPassageAuthImplementation,
passageAuthClient,
} from 'src/auth/passageAuth'
function createAuth() {
if (
window.APP_CONFIG?.webConfigParams?.auth_provider === 'local' ||
process.env.AUTH_PROVIDER === 'local'
) {
const authImplementation = createLocalAuthImplementation(localAuthClient)
return createAuthentication(authImplementation)
} else if (window.APP_CONFIG?.webConfigParams?.auth_provider === 'passage') {
const authImplementation =
createPassageAuthImplementation(passageAuthClient)
return createAuthentication(authImplementation)
} else {
throw Error('Authentication not implemented')
}
}
export const { AuthProvider, useAuth } = createAuth()