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

Cbrelease 3.0.1 rc2 task56217 #71

Open
wants to merge 4 commits into
base: cbrelease-3.0.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions src/models/user.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,5 @@ export interface ISunbirdbUserResponse {
firstName: string
lastName: string
userId: string
userOrgId: string
}
94 changes: 53 additions & 41 deletions src/protectedApi_v8/user/profile-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ profileDeatailsApi.post('/createUser', async (req, res) => {
const sbemailVerified_ = true
const sbfirstName_ = req.body.personalDetails.firstName
const sblastName_ = req.body.personalDetails.lastName
// For controlling the sent email function
const isEmailRequired = (req.body.personalDetails.isEmailRequired) ? req.body.personalDetails.isEmailRequired : true
const sbDesignation = (req.body.personalDetails.designation) ? req.body.personalDetails.designation : ''

const searchresponse = await axios({
...axiosRequestConfig,
Expand Down Expand Up @@ -293,6 +296,12 @@ profileDeatailsApi.post('/createUser', async (req, res) => {
return
}

const arrDesignation = []
const objDesignation = {
designation: (sbDesignation) ? sbDesignation : '',
}
arrDesignation.push(objDesignation)
const sbUserOrgId = sbUserReadResponse.data.result.response.rootOrgId
const sbProfileUpdateReq = {
profileDetails: {
employmentDetails: {
Expand All @@ -303,6 +312,7 @@ profileDeatailsApi.post('/createUser', async (req, res) => {
primaryEmail: sbemail_,
surname: sblastName_,
},
professionalDetails: arrDesignation,
},
userId: sbUserId,
}
Expand All @@ -320,62 +330,64 @@ profileDeatailsApi.post('/createUser', async (req, res) => {
res.status(400).send(failedToUpdateUser)
return
}

const passwordResetRequest = {
key: 'email',
type: 'email',
userId: sbUserId,
}

logInfo('Sending Password reset request -> ' + passwordResetRequest)
const passwordResetResponse = await axios({
...axiosRequestConfig,
data: { request: passwordResetRequest },
headers: {
Authorization: CONSTANTS.SB_API_KEY,
},
method: 'POST',
url: API_END_POINTS.kongUserResetPassword,
})
logInfo('Received response from password reset -> ' + passwordResetResponse)

if (passwordResetResponse.data.params.status === 'success') {
const welcomeMailRequest = {
allowedLoging: 'You can use your email to Login',
body: 'Hello',
emailTemplateType: 'iGotWelcome',
firstName: sbUserProfile.firstName,
link: passwordResetResponse.data.result.link,
mode: 'email',
orgName: sbChannel,
recipientEmails: [ sbemail_ ],
setPasswordLink: true,
subject: 'Welcome Email',
welcomeMessage: 'Hello',
if (isEmailRequired) {
const passwordResetRequest = {
key: 'email',
type: 'email',
userId: sbUserId,
}

const welcomeMailResponse = await axios({
logInfo('Sending Password reset request -> ' + passwordResetRequest)
const passwordResetResponse = await axios({
...axiosRequestConfig,
data: { request: welcomeMailRequest },
data: { request: passwordResetRequest },
headers: {
Authorization: CONSTANTS.SB_API_KEY,
},
method: 'POST',
url: API_END_POINTS.kongSendWelcomeEmail,
url: API_END_POINTS.kongUserResetPassword,
})

if (welcomeMailResponse.data.params.status !== 'success') {
res.status(500).send('Failed to send Welcome Email.')
logInfo('Received response from password reset -> ' + passwordResetResponse)

if (passwordResetResponse.data.params.status === 'success') {
const welcomeMailRequest = {
allowedLoging: 'You can use your email to Login',
body: 'Hello',
emailTemplateType: 'iGotWelcome',
firstName: sbUserProfile.firstName,
link: passwordResetResponse.data.result.link,
mode: 'email',
orgName: sbChannel,
recipientEmails: [ sbemail_ ],
setPasswordLink: true,
subject: 'Welcome Email',
welcomeMessage: 'Hello',
}

const welcomeMailResponse = await axios({
...axiosRequestConfig,
data: { request: welcomeMailRequest },
headers: {
Authorization: CONSTANTS.SB_API_KEY,
},
method: 'POST',
url: API_END_POINTS.kongSendWelcomeEmail,
})

if (welcomeMailResponse.data.params.status !== 'success') {
res.status(500).send('Failed to send Welcome Email.')
return
}
} else {
res.status(500).send('Failed to reset the password for user.')
return
}
} else {
res.status(500).send('Failed to reset the password for user.')
return
}

const sbUserProfileResponse: Partial<ISunbirdbUserResponse> = {
email: sbemail_, firstName: sbfirstName_, lastName: sblastName_,
userId: sbUserId,
userOrgId: sbUserOrgId,
}
res.send(sbUserProfileResponse)
}
Expand Down
2 changes: 1 addition & 1 deletion src/protectedApi_v8/workallocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,4 +464,4 @@ workAllocationApi.get('/getUserCompetencies/:userId', async (req, res) => {
}
)
}
})
})
68 changes: 66 additions & 2 deletions src/utils/whitelistApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1222,13 +1222,69 @@ export const API_LIST = {
ROLE_CHECK: [
ROLE.PUBLIC,
],
},'/authApi/readCert/:certId': {
}, '/authApi/readCert/:certId': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},'/proxies/v8/searchBy/:key': {
}, '/proxies/v8/searchBy/:key': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/action/framework/v3/read/:id': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/action/framework/v3/category/master/create': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/action/framework/v3/category/master/search': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/action/framework/v3/category/master/read/:id': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/action/framework/v3/category/create': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/action/framework/v3/category/read/:id': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/action/framework/v3/category/retire/:id': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/action/framework/v3/term/create': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
Expand Down Expand Up @@ -1409,5 +1465,13 @@ export const API_LIST = {
'/protected/v8/connections/v2/update/connection',
'/protected/v8/user/profileDetails/createUserWithoutInvitationEmail',
'/proxies/v8/searchBy/:key',
'/proxies/v8/action/framework/v3/read/:id',
'/proxies/v8/action/framework/v3/category/master/create',
'/proxies/v8/action/framework/v3/category/master/search',
'/proxies/v8/action/framework/v3/category/master/read/:id',
'/proxies/v8/action/framework/v3/category/create',
'/proxies/v8/action/framework/v3/category/read/:id',
'/proxies/v8/action/framework/v3/category/retire/:id',
'/proxies/v8/action/framework/v3/term/create',
],
}