Fix API authentication page keys not able to hide

This commit is contained in:
Joshen Lim committed 2022-07-15 16:52:03 +08:00
1 parent 4c38fa7517
commit e80300aa7b
2 files changed
+22 -18

No files matched your search

@@ -2,7 +2,13 @@ import Link from 'next/link'
import Snippets from '../Snippets'
import CodeSnippet from '../CodeSnippet'
export default function Authentication({ autoApiService, selectedLang }) {
export default function Authentication({ autoApiService, selectedLang, showApiKey }) {
// [Joshen] ShowApiKey should really be a boolean, its confusing
const defaultApiKey =
showApiKey !== 'SUPABASE_KEY' ? autoApiService.defaultApiKey : 'SUPABASE_CLIENT_API_KEY'
const serviceApiKey =
showApiKey !== 'SUPABASE_KEY' ? autoApiService.serviceApiKey : 'SUPABASE_SERVICE_KEY'
return (
<>
<h2 className="doc-heading">Authentication</h2>
@@ -44,19 +50,13 @@ export default function Authentication({ autoApiService, selectedLang }) {
<article className="code">
<CodeSnippet
selectedLang={selectedLang}
snippet={Snippets.authKey(
'CLIENT API KEY',
'SUPABASE_KEY',
autoApiService.defaultApiKey
)}
snippet={Snippets.authKey('CLIENT API KEY', 'SUPABASE_KEY', defaultApiKey)}
/>
<CodeSnippet
selectedLang={selectedLang}
snippet={Snippets.authKeyExample(
autoApiService.defaultApiKey,
autoApiService.endpoint,
{ showBearer: false }
)}
snippet={Snippets.authKeyExample(defaultApiKey, autoApiService.endpoint, {
showBearer: false,
})}
/>
</article>
</div>
@@ -84,15 +84,13 @@ export default function Authentication({ autoApiService, selectedLang }) {
<article className="code">
<CodeSnippet
selectedLang={selectedLang}
snippet={Snippets.authKey('SERVICE KEY', 'SERVICE_KEY', autoApiService.serviceApiKey)}
snippet={Snippets.authKey('SERVICE KEY', 'SERVICE_KEY', serviceApiKey)}
/>
<CodeSnippet
selectedLang={selectedLang}
snippet={Snippets.authKeyExample(
autoApiService.serviceApiKey,
autoApiService.endpoint,
{ keyName: 'SERVICE_KEY' }
)}
snippet={Snippets.authKeyExample(serviceApiKey, autoApiService.endpoint, {
keyName: 'SERVICE_KEY',
})}
/>
</article>
</div>
+7 -1
View File
@@ -243,7 +243,13 @@ const GeneralContent = ({ autoApiService, selectedLang, page, showApiKey }: any)
if (selected == 'intro' || selected == null)
return <Introduction autoApiService={autoApiService} selectedLang={selectedLang} />
if (selected == 'auth')
return <Authentication autoApiService={autoApiService} selectedLang={selectedLang} />
return (
<Authentication
autoApiService={autoApiService}
selectedLang={selectedLang}
showApiKey={showApiKey}
/>
)
if (selected == 'users')
return (
<UserManagement