Skip to content

Commit 2f475ed

Browse files
authored
28799 - Disallow Maximus users to perform certain actions (#837)
* 28799 - Disallow Maximus users to perform certain actions * updated in response to Sev's comments * fixed in response to Sev's comment * removed async since it's not needed
1 parent d949525 commit 2f475ed

12 files changed

Lines changed: 90 additions & 9 deletions

File tree

app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "name-request",
3-
"version": "5.5.40",
3+
"version": "5.5.41",
44
"private": true,
55
"appName": "Name Request UI",
66
"sbcName": "SBC Common Components",

app/src/App.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,12 @@ export default class App extends Mixins(
174174
@Getter getIncorporateNowErrorStatus!: boolean
175175
@Getter getNrId!: number
176176
@Getter isAuthenticated!: boolean
177-
@Getter isRoleStaff!: boolean
177+
// @Getter isRoleStaff!: boolean
178178
@Getter isMobile!: boolean
179179
// @Getter isNewBusiness!: boolean
180180
181181
// Global actions
182+
@Action fetchAuthorizedActions!: () => void
182183
@Action resetAnalyzeName!: ActionBindingIF
183184
@Action setName!: ActionBindingIF
184185
@Action setDisplayedComponent!: ActionBindingIF
@@ -304,6 +305,9 @@ export default class App extends Mixins(
304305
this.staffPaymentErrorDialog = true
305306
}
306307
})
308+
309+
// fetch the user's authorized actions
310+
this.fetchAuthorizedActions()
307311
}
308312
309313
/** Fetches and stores the current JS date. */

app/src/components/existing-request/nr-approved-gray-box.vue

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
v-else
7676
class="amalgamate-now-btn mt-30"
7777
min-width="20rem"
78-
:disabled="disabled"
78+
:disabled="disabled || !isAmalgamationAllowed"
7979
@click="$emit('affiliateYourBusiness')"
8080
>
8181
<strong>Amalgamate Now</strong>
@@ -102,9 +102,9 @@
102102
</v-btn>
103103
<v-btn
104104
v-else
105-
class="amalgamate-now-btn mt-30"
105+
class="continue-in-btn mt-30"
106106
min-width="20rem"
107-
:disabled="disabled"
107+
:disabled="disabled || !isContinuationInAllowed"
108108
@click="$emit('affiliateYourBusiness')"
109109
>
110110
<strong>Begin Continuation</strong>
@@ -241,7 +241,7 @@ import { Component, Mixins, Prop } from 'vue-property-decorator'
241241
import { Getter } from 'vuex-class'
242242
import { CommonMixin } from '@/mixins'
243243
import { NameRequestI } from '@/interfaces'
244-
import { EntityTypes, NrRequestActionCodes, NrState } from '@/enums'
244+
import { AuthorizedActions, EntityTypes, NrRequestActionCodes, NrState } from '@/enums'
245245
import ContactInfo from '@/components/common/contact-info.vue'
246246
247247
@Component({
@@ -257,6 +257,7 @@ export default class NrApprovedGrayBox extends Mixins(CommonMixin) {
257257
258258
@Getter getNr!: Partial<NameRequestI>
259259
@Getter getIsLearBusiness!: boolean
260+
@Getter getAuthorizedActions!: AuthorizedActions[]
260261
261262
isBusinesCheckDone = false
262263
@@ -370,6 +371,16 @@ export default class NrApprovedGrayBox extends Mixins(CommonMixin) {
370371
this.isApprovedOrConsentUnRequired
371372
)
372373
}
374+
375+
/** Check if amalgamation is allowed based on user actions */
376+
get isAmalgamationAllowed (): boolean {
377+
return this.getAuthorizedActions.includes(AuthorizedActions.AMALGAMATION_FILING)
378+
}
379+
380+
/** Check if continuation in is allowed based on user actions */
381+
get isContinuationInAllowed (): boolean {
382+
return this.getAuthorizedActions.includes(AuthorizedActions.CONTINUATION_IN_FILING)
383+
}
373384
}
374385
375386
</script>

app/src/components/new-request/search.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@
320320
<v-btn
321321
id="action-now-button"
322322
class="px-9"
323+
:disabled="(isAmalgamation && !isAmalgamationAllowed) || (isContinuationIn && !isContinuationInAllowed)"
323324
@click="actionNowClicked()"
324325
>
325326
{{ actionNowButtonText }}
@@ -416,7 +417,7 @@ import RequestAction from '@/components/new-request/search-components/request-ac
416417
import XproFederalBullets from '@/components/new-request/search-components/xpro-federal-bullets.vue'
417418
import SocietiesInfo from '@/components/dialogs/societies-info-dialog.vue'
418419
419-
import { EntityTypes } from '@/enums'
420+
import { AuthorizedActions, EntityTypes } from '@/enums'
420421
import { CommonMixin, NrAffiliationMixin, SearchMixin } from '@/mixins'
421422
import { Designations, XproMapping } from '@/list-data'
422423
import { Navigate } from '@/plugins'
@@ -446,7 +447,8 @@ export default class Search extends Mixins(CommonMixin, NrAffiliationMixin, Sear
446447
@Action setSocietiesModalVisible!: ActionBindingIF
447448
448449
@Getter getIsLearBusiness!: boolean
449-
@Getter isRoleStaff!: boolean
450+
// @Getter isRoleStaff!: boolean
451+
@Getter getAuthorizedActions!: string[]
450452
451453
// Constant
452454
readonly colinLink = sessionStorage.getItem('CORPORATE_ONLINE_URL')
@@ -681,6 +683,16 @@ export default class Search extends Mixins(CommonMixin, NrAffiliationMixin, Sear
681683
return null
682684
}
683685
686+
/** Check if amalgamation is allowed based on user actions */
687+
get isAmalgamationAllowed (): boolean {
688+
return this.getAuthorizedActions.includes(AuthorizedActions.AMALGAMATION_FILING)
689+
}
690+
691+
/** Check if continuation in is allowed based on user actions */
692+
get isContinuationInAllowed (): boolean {
693+
return this.getAuthorizedActions.includes(AuthorizedActions.CONTINUATION_IN_FILING)
694+
}
695+
684696
get showCheckNameButton (): boolean {
685697
// Conditional for "New BC-based business" Flow.
686698
// Show button if we're in "Start a new BC-based business" and non-numbered entity is selected.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/** List of authorized actions (permissions). */
2+
export enum AuthorizedActions {
3+
AMALGAMATION_FILING = 'AMALGAMATION_FILING',
4+
CONTINUATION_IN_FILING = 'CONTINUATION_IN_FILING'
5+
}

app/src/enums/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * from './account-type'
22
export * from './advanced-search-tabs'
3+
export * from './authorized-actions'
34
export * from './company-types'
45
export * from './entity-types'
56
export * from './furnished'

app/src/interfaces/state-interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import { AuthorizedActions } from '@/enums'
12
import { NewRequestIF } from '@/interfaces/new-request-interface'
23
import { NameCheckModelIF, StaffPaymentIF, RefundParamsIF } from '@/interfaces'
34

45
export interface StateModelIF {
56
common: {
67
currentJsDate: Date,
78
keycloakRoles: Array<string>
9+
authorizedActions: Array<AuthorizedActions>
810
}
911
newRequestModel: NewRequestIF
1012
staffPayment: StaffPaymentIF

app/src/services/business-services.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,20 @@ export default class BusinessServices {
2929

3030
return axios.post(url, businessRequest, { headers: extraHeaders })
3131
}
32+
33+
/**
34+
* Get authorized actions from business/legal api.
35+
* @returns response object
36+
*/
37+
static async getAuthorizedActions (): Promise<any> {
38+
const url = `${this.legalApiUrl()}/permissions`
39+
40+
// Add API gateway-specific headers (in addition to interceptor)
41+
const extraHeaders = GetFeatureFlag('use-business-api-gw-url') ? {
42+
'Account-Id': JSON.parse(sessionStorage.getItem('CURRENT_ACCOUNT'))?.id || '',
43+
'X-Apikey': process.env.VUE_APP_BUSINESS_API_KEY || ''
44+
} : {}
45+
46+
return axios.get(url, { headers: extraHeaders })
47+
}
3248
}

app/src/store/actions.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import querystring from 'qs'
22
import axios from 'axios'
33
import {
4+
AuthorizedActions,
45
CompanyTypes,
56
EntityStates,
67
EntityTypes,
@@ -18,6 +19,7 @@ import {
1819
import { BAD_REQUEST, NOT_FOUND, OK, SERVICE_UNAVAILABLE } from 'http-status-codes'
1920
import removeAccents from 'remove-accents'
2021
import { GetFeatureFlag, Sleep, sanitizeName } from '@/plugins'
22+
import BusinessServices from '@/services/business-services'
2123
import NamexServices from '@/services/namex-services'
2224
import { appBaseURL } from '../router/router'
2325
import { DFLT_MIN_LENGTH, DFLT_MAX_LENGTH, MRAS_MIN_LENGTH, MRAS_MAX_LENGTH }
@@ -747,6 +749,22 @@ export const setKeycloakRoles = ({ commit }, keycloakRoles: string[]): void => {
747749
commit('mutateKeycloakRoles', keycloakRoles)
748750
}
749751

752+
export const setAuthorizedActions = ({ commit }, authorizedActions: AuthorizedActions[]): void => {
753+
commit('mutateAuthorizedActions', authorizedActions)
754+
}
755+
756+
export const fetchAuthorizedActions = async ({ commit }): Promise<void> => {
757+
try {
758+
const response = await BusinessServices.getAuthorizedActions()
759+
const authorizedActions = response.data.authorizedPermissions || []
760+
commit('mutateAuthorizedActions', authorizedActions)
761+
} catch (error) {
762+
// eslint-disable-next-line no-console
763+
console.error('Error fetching authorized actions:', error)
764+
commit('mutateAuthorizedActions', [])
765+
}
766+
}
767+
750768
export const setStaffPayment = ({ commit }, staffPayment: StaffPaymentIF): void => {
751769
commit('mutateStaffPayment', staffPayment)
752770
}

app/src/store/getters.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
SubmissionTypeT
2929
} from '@/interfaces'
3030
import {
31+
AuthorizedActions,
3132
CompanyTypes,
3233
EntityTypes,
3334
Location,
@@ -1144,6 +1145,11 @@ export const getKeycloakRoles = (state: StateIF): Array<string> => {
11441145
return state.stateModel.common.keycloakRoles
11451146
}
11461147

1148+
/** The user's authorized actions. */
1149+
export const getAuthorizedActions = (state: StateIF): Array<AuthorizedActions> => {
1150+
return state.stateModel.common.authorizedActions
1151+
}
1152+
11471153
/** Whether the user has "staff" keycloak role. */
11481154
export const isRoleStaff = (state: StateIF): boolean => {
11491155
return state.stateModel.common.keycloakRoles.includes('staff')

0 commit comments

Comments
 (0)