@@ -32,11 +32,12 @@ import { CertificateRevocation } from 'src/app/backend-api/identity-registry';
3232import { getReasonOptionFromRevocationReason , ReasonOption } from 'src/app/common/certRevokeInfo' ;
3333import { migrateVesselAttributes } from 'src/app/common/filterObject' ;
3434import { ItemFormComponent } from '../item-form/item-form.component' ;
35- import { getMrnPrefixFromOrgMrn } from 'src/app/common/mrnUtil' ;
35+ import { getMrnPrefixFromOrgMrn , isUserEditingTheirOwnData } from 'src/app/common/mrnUtil' ;
3636import { ORG_ADMIN_AT_MIR } from 'src/app/common/variables' ;
3737import { ItemTableComponent } from "../item-table/item-table.component" ;
3838import { InputGeometryComponent } from '../input-geometry/input-geometry.component' ;
3939import { preprocessToShow } from 'src/app/common/itemPreprocessor' ;
40+ import { loadLang } from 'src/app/common/translateHelper' ;
4041
4142@Component ( {
4243 selector : 'app-item-view' ,
@@ -109,7 +110,7 @@ export class ItemViewComponent {
109110 private translate : TranslateService ,
110111 private notifier : NotifierService ,
111112 private fileHelper : FileHelperService ,
112- authService : AuthService ,
113+ private authService : AuthService ,
113114 @Inject ( LOCALE_ID ) public locale : string ,
114115 ) {
115116 for ( const reason in CertificateRevocation . RevocationReasonEnum ) {
@@ -119,13 +120,25 @@ export class ItemViewComponent {
119120 authService . getOrgMrnFromToken ( ) . then ( ( orgMrn ) => {
120121 this . orgMrn = orgMrn ;
121122 } ) ;
123+
124+ loadLang ( translate ) ;
122125 }
123126
124127 ngOnChanges ( simpleChange : any ) {
125128 if ( ! simpleChange . item || ! simpleChange . item . currentValue )
126129 return ;
127130
128131 this . item = simpleChange . item . currentValue && simpleChange . item . currentValue ;
132+
133+ // give permission when user access their own profile
134+ if ( this . itemType === ItemType . User && ! this . hasEditPermission ) {
135+ this . authService . getUserMrnFromToken ( ) . then ( ( userMrn ) => {
136+ if ( isUserEditingTheirOwnData ( this . item . mrn , userMrn ) ) {
137+ this . hasEditPermission = true ;
138+ }
139+ } ) ;
140+ }
141+
129142 if ( this . item && this . itemType === ItemType . Role ) {
130143 this . itemId = this . item . id ;
131144 this . setForm ( ) ;
0 commit comments