Skip to content

Commit

Permalink
fix(profile): make people with subscriptions eligible for public profile
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianak committed Oct 8, 2024
1 parent 8438d7d commit be70a23
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module.exports = {
},
isEligibleForProfile(user, args, { user: me, pgdb }) {
if (Roles.userIsMeOrInRoles(user, me, ['admin', 'supporter', 'author'])) {
return Roles.userHasRole(user, 'author') || isEligible(user.id, pgdb)
return Roles.userHasRole(user, 'author') || isEligible(user, pgdb)
}
return null
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ module.exports = async (_, args, context) => {
// Authors always have the option to make their profile public,
// we can skip the DB check if the user has the role 'author'.
const check =
Roles.userHasRole(me, 'author') || (await isEligible(me.id, pgdb))
Roles.userHasRole(me, 'author') || (await isEligible(me, pgdb))
if (!check) {
throw new Error(t('profile/notEligible'))
}
Expand Down
8 changes: 3 additions & 5 deletions packages/backend-modules/republik/lib/profile.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
const hasUserActiveMembership = require('@orbiting/backend-modules-utils/hasUserActiveMembership')
const {
hasUserCandidacies,
hasUserCandidaciesInCandidacyPhase,
hasUserCandidaciesInElectionPhase,
} = require('@orbiting/backend-modules-voting/lib/Candidacy')

exports.isEligible = async (userId, pgdb) => {
return !!(await pgdb.public.memberships.findFirst({
userId,
active: true,
}))
exports.isEligible = async (user, pgdb) => {
return await hasUserActiveMembership(user, pgdb)
}

/**
Expand Down

0 comments on commit be70a23

Please sign in to comment.