Skip to content

Commit

Permalink
Merge pull request #78 from sunbird-cb/secure-email-fix
Browse files Browse the repository at this point in the history
Secure email fix
  • Loading branch information
nitinraj-tarento authored Mar 6, 2023
2 parents 86b42ec + ba5dea4 commit cad9fbd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AfterViewInit, Component, OnInit, OnDestroy, ElementRef, HostListener, ViewChild } from '@angular/core'
import { Router, ActivatedRoute } from '@angular/router'
import * as _ from 'lodash'
import { ProfileV2UtillService } from '../../../home/services/home-utill.service'
import { ProfileV2Service } from '../../../home/services/home.servive'
import { UsersService } from '../../../home/services/users.service'
// import { UsersService } from '../../services/users.service'
Expand Down Expand Up @@ -45,6 +46,7 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy {
constructor(private usersSvc: UsersService, private router: Router,
private route: ActivatedRoute,
private profile: ProfileV2Service,
private profileUtilSvc: ProfileV2UtillService,
private usersService: UsersService) {
}
ngOnInit() {
Expand Down Expand Up @@ -124,7 +126,7 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy {
})
return {
fullName: `${user.firstName} ${user.lastName}`,
email: user.emailId,
email: this.profileUtilSvc.emailTransform(user.emailId),
position: userRole,
role: user.roleInfo.roleName,
}
Expand All @@ -142,7 +144,7 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy {
})
return {
fullName: `${user.firstName} ${user.lastName}`,
email: user.emailId,
email: this.profileUtilSvc.emailTransform(user.emailId),
position: userRole,
role: user.roleInfo.roleName,
}
Expand Down Expand Up @@ -170,7 +172,7 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy {
// }

})
const email = _.get(user, 'profileDetails.personalDetails.primaryEmail')
const email = this.profileUtilSvc.emailTransform(_.get(user, 'profileDetails.personalDetails.primaryEmail'))
if (!user.isDeleted && roles.includes(roldata)) {
usersData.push({
fullName: user ? `${user.firstName} ${user.lastName}` : null,
Expand Down Expand Up @@ -209,7 +211,7 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy {
if (!(user.isDeleted)) {
usersData.push({
fullName: user ? `${user.firstName} ${user.lastName}` : null,
email: email || user.email,
email: this.profileUtilSvc.emailTransform(email) || this.profileUtilSvc.emailTransform(user.email),
position: roles,
userId: user.userId,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, OnInit, ElementRef, HostListener, ViewChild, AfterViewInit,
import { Router, ActivatedRoute } from '@angular/router'
import * as _ from 'lodash'
import { ProfileV2Service } from '../../../home/services/home.servive'
import { ProfileV2UtillService } from '../../services/home-utill.service'
import { UsersService } from '../../services/users.service'

@Component({
Expand Down Expand Up @@ -40,7 +41,7 @@ export class RolesUsersComponent implements OnInit, AfterViewInit, OnDestroy {
}
}

constructor(private usersSvc: UsersService, private router: Router,
constructor(private usersSvc: UsersService, private router: Router, private profileUtilSvc: ProfileV2UtillService,
// tslint:disable-next-line:align
private route: ActivatedRoute, private profile: ProfileV2Service, private usersService: UsersService) {
}
Expand Down Expand Up @@ -117,7 +118,7 @@ export class RolesUsersComponent implements OnInit, AfterViewInit, OnDestroy {
})
return {
fullName: `${user.firstName} ${user.lastName}`,
email: user.emailId,
email: this.profileUtilSvc.emailTransform(user.emailId),
position: userRole,
role: user.roleInfo.roleName,
}
Expand All @@ -135,7 +136,7 @@ export class RolesUsersComponent implements OnInit, AfterViewInit, OnDestroy {
})
return {
fullName: `${user.firstName} ${user.lastName}`,
email: user.emailId,
email: this.profileUtilSvc.emailTransform(user.emailId),
position: userRole,
role: user.roleInfo.roleName,
}
Expand Down Expand Up @@ -169,7 +170,7 @@ export class RolesUsersComponent implements OnInit, AfterViewInit, OnDestroy {
if (!(user.isDeleted)) {
usersData.push({
fullName: user ? `${user.firstName} ${user.lastName}` : null,
email: email || user.email,
email: this.profileUtilSvc.emailTransform(email) || this.profileUtilSvc.emailTransform(user.email),
position: this.getRoleList(user).toString().replace(',', ', '),
userId: user.userId,
})
Expand Down Expand Up @@ -210,7 +211,8 @@ export class RolesUsersComponent implements OnInit, AfterViewInit, OnDestroy {
user => {
return {
fullName: `${user.firstName} ${user.lastName}`,
email: _.get(user, 'profileDetails.personalDetails.primaryEmail') || user.email,
email: this.profileUtilSvc.emailTransform(_.get(user, 'profileDetails.personalDetails.primaryEmail'))
|| this.profileUtilSvc.emailTransform(user.email),
position: this.getRoleList(user).toString().replace(',', ', '),
userId: user.userId,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { UsersService } from '../../services/users.service'
import { MatSnackBar } from '@angular/material/snack-bar'
import { environment } from 'src/environments/environment'
import { LoaderService } from '../../services/loader.service'
import { ProfileV2UtillService } from '../../services/home-utill.service'
@Component({
selector: 'ws-app-users-view',
templateUrl: './users-view.component.html',
Expand Down Expand Up @@ -54,6 +55,7 @@ export class UsersViewComponent implements OnInit {
private configSvc: ConfigurationsService,
private snackBar: MatSnackBar,
private events: EventService,
private profileUtilSvc: ProfileV2UtillService,
) {
this.Math = Math
this.currentUser = this.configSvc.userProfile && this.configSvc.userProfile.userId
Expand Down Expand Up @@ -220,7 +222,7 @@ export class UsersViewComponent implements OnInit {
user.organisations.forEach((org: { organisationId: string, roles: any }) => {
roles = org.roles
})
const email = _.get(user, 'profileDetails.personalDetails.primaryEmail')
const email = this.profileUtilSvc.emailTransform(_.get(user, 'profileDetails.personalDetails.primaryEmail')) || ''
if (active === user.isDeleted) {
usersData.push({
fullname: user ? `${user.firstName} ${user.lastName}` : null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,11 @@ export class ProfileV2UtillService {
.get<any>(API_END_POINTS.USER_BADGE_RECENT)
.pipe(map(notifications => notifications))
}

emailTransform(value: string): any {
if (value !== undefined) {
return value.replace('@', '[at]').replace(/\./g, '[dot]')
}

}
}

0 comments on commit cad9fbd

Please sign in to comment.