Skip to content

Commit

Permalink
Merge pull request #58 from dreampipcom/dev
Browse files Browse the repository at this point in the history
r007
  • Loading branch information
angeloreale authored Aug 30, 2024
2 parents 0d3db2d + 29b83db commit 51861f5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/auth/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ export const GetSession = async ({ cookies = '' }) => {
// schema sanitizer
const allUsersSideEffects = async ({ user }: any) => {
if (!user) return;
const userServices = user.servicesIds || [];
const userAbilities = user.abilitiesIds || [];
const services = await GetPrivateCommonServices({});
const abilities = await GetPrivateCommonAbilities({});
const commonServices = services.map((service: any) => service?.id).map((el: any) => el);
const commonAbilities = abilities.map((ability: any) => ability?.id).map((el: any) => el);

const [dpcpAbility] = await GetPrivateAbilities({ type: 'R', target: 'dpcp-vibemodulator', action: 'view-listings' });

const nextAbilities = _.uniq([...commonAbilities, ...user.abilitiesIds, dpcpAbility?.id]);
const nextServices = _.uniq([...commonServices, ...user.servicesIds]);
const nextAbilities = _.uniq([...commonAbilities, ...userAbilities, dpcpAbility?.id]);
const nextServices = _.uniq([...commonServices, ...userServices]);

await UpdatePrivateUserServices({ user, services: nextServices, upsert: false });
await UpdatePrivateUserAbilities({
Expand Down

0 comments on commit 51861f5

Please sign in to comment.