This repository has been archived by the owner on Dec 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: parse resources and scopes if they are strings to allow setting…
… them by env
- Loading branch information
Showing
5 changed files
with
43 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useRuntimeConfig } from '#imports' | ||
import type { LogtoNuxtConfig } from './types' | ||
|
||
export const useConfig = () => { | ||
const config = useRuntimeConfig().logto | ||
|
||
|
||
let resources = config.resources | ||
if (resources && typeof resources === 'string') { | ||
try { | ||
resources = JSON.parse(config.resources) | ||
} catch (e) { | ||
console.warn("Failed to parse resources string") | ||
} | ||
} | ||
|
||
let scopes = config.scopes | ||
if (scopes && typeof scopes === 'string') { | ||
try { | ||
scopes = JSON.parse(config.scopes) | ||
} catch (e) { | ||
console.warn("Failed to parse scopes string") | ||
} | ||
} | ||
|
||
return { ...config, scopes, resources } as unknown as LogtoNuxtConfig | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters