Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
add NEXT_PUBLIC_LOCAL_USER flag (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
brekk authored Dec 14, 2021
1 parent bb91676 commit 286db77
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
NEXT_PUBLIC_API_URL=https://api.ironfish.network
API_URL=https://api.ironfish.network
NEXT_PUBLIC_MAGIC_PUBLISHABLE_KEY=test
NEXT_PUBLIC_LOCAL_USER=true
35 changes: 35 additions & 0 deletions hooks/useLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,39 @@ export function useLogin(config: LoginProps = {}) {

export type LoginContext = ReturnType<typeof useLogin>

export const useLocalLogin = () => ({
checkLoggedIn: () => true,
checkLoading: () => false,
checkFailed: () => false,
// eslint-disable-next-line @typescript-eslint/no-empty-function
setError: () => {},
error: '',
status: STATUS.LOADED,
// eslint-disable-next-line @typescript-eslint/no-empty-function
setStatus: () => {},
metadata: {
id: 111,
created_at: '2021-10-30T23:28:59.505Z',
updated_at: '2021-10-30T23:43:28.555Z',
email: '[email protected]',
graffiti: 'cooldev',
total_points: 1100,
country_code: 'USA',
email_notifications: false,
last_login_at: '2021-10-30T23:29:49.101Z',
discord: 'coolcooldev',
telegram: '',
confirmation_token: '01FNSJW53E9J029SKXYA2020KN',
confirmed_at: '2021-10-30T23:43:28.554Z',
github: '',
},
magicMetadata: {
issuer: 'did:ethr:0xFfcD8602De681449Fa70C304096a84e014Fa123C',
publicAddress: '0xFfcD8602De681449Fa70C304096a84e014Fa123C',
email: '[email protected]',
isMfaEnabled: false,
phoneNumber: null,
},
})

export default useLogin
7 changes: 5 additions & 2 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import 'styles/globals.css'
import Head from 'next/head'
import type { AppProps } from 'next/app'
import ResponsiveToolkit from 'components/ResponsiveToolkit'
import { useLogin } from 'hooks/useLogin'
import { useLogin, useLocalLogin } from 'hooks/useLogin'

const LOCAL_MODE = process.env.NEXT_PUBLIC_LOCAL_USER || false
const loginHook = LOCAL_MODE ? useLocalLogin : useLogin

function MyApp({ Component: Page, pageProps }: AppProps) {
const $login = useLogin()
const $login = loginHook()
const { metadata } = $login
return (
<>
Expand Down

1 comment on commit 286db77

@vercel
Copy link

@vercel vercel bot commented on 286db77 Dec 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.