Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

26014 - auth web permissions updates #3290

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions auth-web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion auth-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auth-web",
"version": "2.8.15",
"version": "2.9.0",
"appName": "Auth Web",
"sbcName": "SBC Common Components",
"private": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
class="value"
aria-labelledby="adminContact"
>
<OrgAdminContact />
<OrgAdminContact :orgId="orgId"/>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix page refresh where the contact refreshes to the current accounts contact rather than the account on the current url

</div>
</div>

Expand Down Expand Up @@ -298,6 +298,7 @@ export default defineComponent({
AccountMailingAddress,
AccountAccessType
},
props: ['orgId'],
setup (props, { root }) {
const codesStore = useCodesStore()
const orgStore = useOrgStore()
Expand All @@ -309,7 +310,6 @@ export default defineComponent({
currentOrgPaymentType,
currentOrgAddress,
permissions,
getAccountFromSession,
anonAccount,
isGovmAccount,
isStaffAccount,
Expand Down Expand Up @@ -343,16 +343,15 @@ export default defineComponent({
isBusinessAccount: computed(() => orgStore.isBusinessAccount),
baseAddress: computed(() => currentOrgAddress.value),

isStaff: computed(() => userStore.currentUser.roles.includes(Role.Staff)) || userStore.currentUser.roles.includes(Role.ContactCentreStaff),
isStaff: computed(() => userStore.currentUser.roles.includes(Role.Staff)) || userStore.currentUser.roles.includes(Role.ExternalStaffReadonly),
isSuspendButtonVisible: computed(() => (
(currentOrganization.value.statusCode === AccountStatus.ACTIVE ||
currentOrganization.value.statusCode === AccountStatus.SUSPENDED) &&
userStore.currentUser.roles.includes(Role.StaffSuspendAccounts)
)),
isDeactivateButtonVisible: computed(() => currentOrganization.value?.statusCode !== AccountStatus.INACTIVE),
canChangeAccessType: computed(() => (
userStore.currentUser.roles.includes(Role.StaffManageAccounts) &&
!userStore.currentUser.roles.includes(Role.ContactCentreStaff)
userStore.currentUser.roles.includes(Role.StaffManageAccounts)
)),
isAdminContactViewable: computed(() => [Permission.VIEW_ADMIN_CONTACT].some(per => permissions.value.includes(per))),
isAccountStatusActive: computed(() => currentOrganization.value.statusCode === AccountStatus.ACTIVE),
Expand All @@ -368,7 +367,7 @@ export default defineComponent({
currentOrgAddress.value ? Object.keys(currentOrgAddress.value).length === 0 : true
)),
nameChangeNotAllowed: computed(() => (anonAccount.value || isGovmAccount.value)) &&
userStore.currentUser.roles.includes(Role.ContactCentreStaff)
userStore.currentUser.roles.includes(Role.ExternalStaffReadonly)
})

const suspensionSelectRules = [
Expand Down Expand Up @@ -591,8 +590,6 @@ export default defineComponent({
}

onMounted(async () => {
const accountSettings = getAccountFromSession()
await orgStore.syncOrganization(accountSettings?.id)
Copy link
Collaborator Author

@ochiu ochiu Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let the higher level sync from account settings(takes orgId path param now) take care of this or it conflicts with the orgId on the url on refresh.

setAccountChangedHandler(setup)
await setup()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import { Component, Prop, Vue } from 'vue-property-decorator'
import {
Member,
MembershipType,
Expand All @@ -49,12 +49,13 @@ import { useOrgStore } from '@/stores/org'

})
export default class OrgAdminContact extends Vue {
@Prop() private orgId: number
private activeOrgMembers!: Member[]
private readonly syncActiveOrgMembers!: () => Member[]
private readonly syncActiveOrgMembers!: (orgId: number) => Member[]
private readonly currentOrganization!: Organization

private async mounted () {
this.syncActiveOrgMembers()
this.syncActiveOrgMembers(this.orgId)
}

private get getActiveAdmins (): Member[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<template #[`item.action`]="{ item }">
<!-- Resend Invitation -->
<v-btn
v-if="canApproveOrDeny()"
v-can:EDIT_USER.hide
icon
class="mr-1"
aria-label="Resend invitation"
Expand All @@ -43,7 +43,7 @@

<!-- Remove Invitation -->
<v-btn
v-if="canApproveOrDeny()"
v-can:EDIT_USER.hide
icon
aria-label="Remove Invitation"
title="Remove Invitation"
Expand All @@ -57,72 +57,80 @@
</template>

<script lang="ts">
import { Component, Emit, Vue } from 'vue-property-decorator'
import { computed, defineComponent, reactive, ref, toRefs } from '@vue/composition-api'

Check failure on line 60 in auth-web/src/components/auth/account-settings/team-management/InvitationsDataTable.vue

View workflow job for this annotation

GitHub Actions / account-ui-ci / linting-npm (20.5.1)

'ref' is defined but never used
import { storeToRefs } from 'pinia'
import CommonUtils from '@/util/common-util'

Check failure on line 62 in auth-web/src/components/auth/account-settings/team-management/InvitationsDataTable.vue

View workflow job for this annotation

GitHub Actions / account-ui-ci / linting-npm (20.5.1)

Imports should be sorted alphabetically
import { Invitation } from '@/models/Invitation'
import { Role } from '@/util/constants'
import { mapState } from 'pinia'
import { useOrgStore } from '@/stores/org'
import { useUserStore } from '@/stores/user'

@Component({
computed: {
...mapState(useOrgStore, ['pendingOrgInvitations']),
...mapState(useUserStore, ['currentUser'])
}
})
export default class InvitationsDataTable extends Vue {
private readonly pendingOrgInvitations!: Invitation[]
readonly headerInvitations = [
{
text: 'Email',
align: 'left',
sortable: true,
value: 'recipientEmail'
},
{
text: 'Invitation Sent',
align: 'left',
sortable: true,
value: 'sentDate'
},
{
text: 'Expires',
align: 'left',
sortable: true,
value: 'expiresOn'
},
{
text: 'Actions',
align: 'right',
value: 'action',
sortable: false
}
]
export default defineComponent({
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To composition-api which handled refresh / syncing issues

name: 'InvitationsDataTable',
emits: ['confirmRemoveInvite', 'resend'],
setup (props, { emit }) {
const orgStore = useOrgStore()
const userStore = useUserStore()

private canApproveOrDeny (): boolean {
return !this.currentUser.roles?.includes(Role.ContactCentreStaff)
}
const { pendingOrgInvitations, currentMembership } = storeToRefs(orgStore)

Check failure on line 74 in auth-web/src/components/auth/account-settings/team-management/InvitationsDataTable.vue

View workflow job for this annotation

GitHub Actions / account-ui-ci / linting-npm (20.5.1)

'currentMembership' is assigned a value but never used
const { currentUser } = storeToRefs(userStore)

Check failure on line 75 in auth-web/src/components/auth/account-settings/team-management/InvitationsDataTable.vue

View workflow job for this annotation

GitHub Actions / account-ui-ci / linting-npm (20.5.1)

'currentUser' is assigned a value but never used

formatDate = CommonUtils.formatDisplayDate
const headerInvitations = [
{
text: 'Email',
align: 'left',
sortable: true,
value: 'recipientEmail'
},
{
text: 'Invitation Sent',
align: 'left',
sortable: true,
value: 'sentDate'
},
{
text: 'Expires',
align: 'left',
sortable: true,
value: 'expiresOn'
},
{
text: 'Actions',
align: 'right',
value: 'action',
sortable: false
}
]

getIndexedTag (tag, index): string {
return `${tag}-${index}`
}
const state = reactive({
indexedInvitations: computed(() =>
pendingOrgInvitations.value.map((item: Invitation, index: number) => ({
index,
...item
})))
})

get indexedInvitations () {
return this.pendingOrgInvitations.map((item, index) => ({
index,
...item
}))
}
function getIndexedTag (tag: string, index: number): string {
return `${tag}-${index}`
}

@Emit()
confirmRemoveInvite () {}
function confirmRemoveInvite (invitation) {
emit('confirm-remove-invite', invitation)
}

@Emit()
resend () {}
}
function resend (invitation) {
emit('resend', invitation)
}

return {
headerInvitations,
...toRefs(state),
formatDate: CommonUtils.formatDisplayDate,
getIndexedTag,
confirmRemoveInvite,
resend
}
}
})
</script>

<style lang="scss" scoped>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
</template>

<script lang="ts">
import { AccessType, LoginSource, Permission, Role } from '@/util/constants'

Check failure on line 234 in auth-web/src/components/auth/account-settings/team-management/MemberDataTable.vue

View workflow job for this annotation

GitHub Actions / account-ui-ci / linting-npm (20.5.1)

'Role' is defined but never used
import { Component, Emit, Prop, Vue } from 'vue-property-decorator'
import { Member, MembershipStatus, MembershipType, Organization, RoleInfo } from '@/models/Organization'
import { mapActions, mapState } from 'pinia'
Expand Down Expand Up @@ -404,10 +404,6 @@
}

private canChangeRole (memberBeingChanged: Member): boolean {
if (this.currentUser.roles?.includes(Role.ContactCentreStaff)) {
return false
}

if (this.currentMembership.membershipStatus !== MembershipStatus.Active) {
return false
}
Expand Down Expand Up @@ -435,11 +431,6 @@
}

private canRemove (memberToRemove: Member): boolean {
// Contact Centre Staff can't remove anyone
if (this.currentUser.roles?.includes(Role.ContactCentreStaff)) {
return false
}

// Can't remove yourself
if (this.currentMembership.user?.username === memberToRemove.user.username) {
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</template>
<template #[`item.action`]="{ item }">
<v-btn
v-if="canApproveOrDeny()"
v-can:EDIT_USER.hide
icon
class="mr-1"
aria-label="Approve user access to this account"
Expand All @@ -39,7 +39,7 @@
<v-icon>mdi-check-circle-outline</v-icon>
</v-btn>
<v-btn
v-if="canApproveOrDeny()"
v-can:EDIT_USER.hide
icon
aria-label="Deny access to this account"
title="Deny access to this account"
Expand All @@ -56,7 +56,6 @@
import { Component, Emit, Prop, Vue } from 'vue-property-decorator'
import { KCUserProfile } from 'sbc-common-components/src/models/KCUserProfile'
import { Member } from '@/models/Organization'
import { Role } from '@/util/constants'
import { mapState } from 'pinia'
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
import moment from 'moment'
Expand Down Expand Up @@ -88,10 +87,6 @@ export default class PendingMemberDataTable extends Vue {
}
]

private canApproveOrDeny (): boolean {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be consistent now with some of the current invitation updates to use permissions.

return !this.currentUser.roles?.includes(Role.ContactCentreStaff)
}

getIndexedTag (tag, index): string {
return `${tag}-${index}`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@
</template>

<script lang="ts">
import { Account, Pages } from '@/util/constants'

Check failure on line 118 in auth-web/src/components/auth/account-settings/transaction/Transactions.vue

View workflow job for this annotation

GitHub Actions / account-ui-ci / linting-npm (20.5.1)

'Account' is defined but never used

Check failure on line 118 in auth-web/src/components/auth/account-settings/transaction/Transactions.vue

View workflow job for this annotation

GitHub Actions / account-ui-ci / linting-npm (20.5.1)

'Pages' is defined but never used
import { MembershipType, OrgPaymentDetails } from '@/models/Organization'

Check failure on line 119 in auth-web/src/components/auth/account-settings/transaction/Transactions.vue

View workflow job for this annotation

GitHub Actions / account-ui-ci / linting-npm (20.5.1)

'MembershipType' is defined but never used
import { Ref, computed, defineComponent, onBeforeUnmount, onMounted, reactive, ref, toRefs, watch } from '@vue/composition-api'
import { useAccountChangeHandler, useTransactions } from '@/composables'
import { BaseTableHeaderI } from '@/components/datatable/interfaces'
Expand All @@ -137,11 +137,11 @@
showExport: { default: true },
title: { default: '' }
},
setup (props, { root }) {

Check failure on line 140 in auth-web/src/components/auth/account-settings/transaction/Transactions.vue

View workflow job for this annotation

GitHub Actions / account-ui-ci / linting-npm (20.5.1)

'root' is defined but never used
const orgStore = useOrgStore()
const currentOrgPaymentDetails = computed(() => orgStore.currentOrgPaymentDetails)
const currentOrganization = computed(() => orgStore.currentOrganization)
const currentMembership = computed(() => orgStore.currentMembership)

Check failure on line 144 in auth-web/src/components/auth/account-settings/transaction/Transactions.vue

View workflow job for this annotation

GitHub Actions / account-ui-ci / linting-npm (20.5.1)

'currentMembership' is assigned a value but never used

const csvErrorDialog: Ref<InstanceType<typeof ModalDialog>> = ref(null)
const csvErrorTextBasic = 'We were unable to process your CSV export. Please try again later.'
Expand Down Expand Up @@ -188,13 +188,6 @@
})

const credit = ref(0)

const isTransactionsAllowed = computed((): boolean => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer needed. Permissions will hide/show this based on 'transaction_history' permission, this has been updated for the auth-api portion. API blocks if there are no appropriate security roles.

return [Account.PREMIUM, Account.STAFF, Account.SBC_STAFF]
.includes(currentOrganization.value.orgType as Account) &&
[MembershipType.Admin, MembershipType.Coordinator].includes(currentMembership.value.membershipTypeCode)
})

const getCredits = async () => {
const accountId = currentOrgPaymentDetails.value?.accountId
if (!accountId || Number(accountId) !== currentOrganization.value?.id) {
Expand All @@ -206,18 +199,12 @@
}

const initialize = () => {
if (!isTransactionsAllowed.value) {
// if the account switching happening when the user is already in the transaction page,
// redirect to account-info if account is not allowed to view transactions
root.$router.push(`/${Pages.MAIN}/${currentOrganization.value.id}/settings/account-info`)
} else {
setAccountChangedHandler(initialize)
setViewAll(props.extended)
clearAllFilters(true)
defaultSearchToOneYear()
loadTransactionList()
getCredits()
}
setAccountChangedHandler(initialize)
setViewAll(props.extended)
clearAllFilters(true)
defaultSearchToOneYear()
loadTransactionList()
getCredits()
}

const exportCSV = async () => {
Expand Down
2 changes: 1 addition & 1 deletion auth-web/src/components/auth/common/ProductTOS.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default defineComponent({
const state = reactive({
termsAccepted: false,
istosTouched: false,
canAcceptTos: computed(() => !userStore?.currentUser?.roles.includes(Role.ContactCentreStaff))
canAcceptTos: computed(() => !userStore?.currentUser?.roles.includes(Role.ExternalStaffReadonly))
})

watch(() => props.isTOSAlreadyAccepted, (newTos, oldTos) => {
Expand Down
4 changes: 4 additions & 0 deletions auth-web/src/components/auth/mixins/AccountMixin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,9 @@ export default class AccountMixin extends Vue {
get isSbcStaffAccount (): boolean {
return this.currentOrganization?.orgType === Account.SBC_STAFF
}

get isExternalStaffAccount (): boolean {
return [Account.CONTACT_CENTRE_STAFF, Account.MAXIMUS_STAFF].includes(this.currentOrganization?.orgType)
}
}
</script>
Loading
Loading