Skip to content

Commit

Permalink
Merge pull request #36 from kinde-oss/peter/fix/ff
Browse files Browse the repository at this point in the history
fix: get feature flags
  • Loading branch information
marcosmartini authored Jul 5, 2023
2 parents 9258689 + ff55946 commit 52b23d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
9 changes: 2 additions & 7 deletions src/session/appRouter/getFlag.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@ const flagDataTypeMap = {
b: 'boolean'
};

const getClaimValue = (claim) => {
const obj = getClaim(claim);
return obj && obj.value;
};

export const getFlag = (code, defaultValue, flagType) => {
const flags = getClaimValue('feature_flags');
const flags = getClaim('feature_flags');
const flag = flags && flags[code] ? flags[code] : {};

if (!flag.v && !defaultValue) {
if (!flag.v && defaultValue == undefined) {
throw Error(
`Flag ${code} was not found, and no default value has been provided`
);
Expand Down
9 changes: 2 additions & 7 deletions src/session/pagesRouter/getFlag.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@ const flagDataTypeMap = {
b: 'boolean'
};

const getClaimValue = (claim, tokenKey = 'access_token') => {
const obj = getClaim(claim, tokenKey);
return obj && obj.value;
};

export const getFlag = (code, defaultValue, flagType) => {
const flags = getClaimValue('feature_flags');
const flags = getClaim('feature_flags');
const flag = flags && flags[code] ? flags[code] : {};

if (!flag.v && !defaultValue) {
if (!flag.v && defaultValue == undefined) {
throw Error(
`Flag ${code} was not found, and no default value has been provided`
);
Expand Down

0 comments on commit 52b23d7

Please sign in to comment.