From 3f257fdc7be64d9535cebe38890d6b92ce0764c2 Mon Sep 17 00:00:00 2001 From: Amit Sengar Date: Mon, 22 Nov 2021 15:08:47 +0530 Subject: [PATCH] Revert "Cbrelease 3.0.1 rc checkup (#72)" This reverts commit 38eaf635d39eb4db3228b92030efd0eca89cf53d. --- src/models/user.model.ts | 1 - src/protectedApi_v8/cohorts.ts | 2 +- src/protectedApi_v8/user/profile-details.ts | 87 ++++++++++----------- src/utils/whitelistApis.ts | 66 +--------------- 4 files changed, 43 insertions(+), 113 deletions(-) diff --git a/src/models/user.model.ts b/src/models/user.model.ts index 966bd3d3..96e4a75e 100644 --- a/src/models/user.model.ts +++ b/src/models/user.model.ts @@ -151,5 +151,4 @@ export interface ISunbirdbUserResponse { firstName: string lastName: string userId: string - userOrgId: string } diff --git a/src/protectedApi_v8/cohorts.ts b/src/protectedApi_v8/cohorts.ts index 07e4f629..f58b4878 100644 --- a/src/protectedApi_v8/cohorts.ts +++ b/src/protectedApi_v8/cohorts.ts @@ -298,7 +298,7 @@ function getUsers(userprofile: IUserProfile): ICohortsUser { if (userprofile.professionalDetails[0].designation !== undefined) { designationValue = userprofile.professionalDetails[0].designation } else { - designationValue = userprofile.professionalDetails[0].designationOther === undefined ? '' : + designationValue = userprofile.professionalDetails[0].designationOther === undefined ? '' : userprofile.professionalDetails[0].designationOther } } diff --git a/src/protectedApi_v8/user/profile-details.ts b/src/protectedApi_v8/user/profile-details.ts index c865b998..4168083d 100644 --- a/src/protectedApi_v8/user/profile-details.ts +++ b/src/protectedApi_v8/user/profile-details.ts @@ -225,8 +225,6 @@ 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 searchresponse = await axios({ ...axiosRequestConfig, @@ -295,7 +293,6 @@ profileDeatailsApi.post('/createUser', async (req, res) => { return } - const sbUserOrgId = sbUserReadResponse.data.result.response.rootOrgId const sbProfileUpdateReq = { profileDetails: { employmentDetails: { @@ -323,64 +320,62 @@ profileDeatailsApi.post('/createUser', async (req, res) => { res.status(400).send(failedToUpdateUser) return } - if (isEmailRequired) { - const passwordResetRequest = { - key: 'email', - type: 'email', - userId: sbUserId, + + 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', } - logInfo('Sending Password reset request -> ' + passwordResetRequest) - const passwordResetResponse = await axios({ + const welcomeMailResponse = await axios({ ...axiosRequestConfig, - data: { request: passwordResetRequest }, + data: { request: welcomeMailRequest }, headers: { Authorization: CONSTANTS.SB_API_KEY, }, method: 'POST', - url: API_END_POINTS.kongUserResetPassword, + url: API_END_POINTS.kongSendWelcomeEmail, }) - 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.') + + 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 } const sbUserProfileResponse: Partial = { email: sbemail_, firstName: sbfirstName_, lastName: sblastName_, userId: sbUserId, - userOrgId: sbUserOrgId, } res.send(sbUserProfileResponse) } diff --git a/src/utils/whitelistApis.ts b/src/utils/whitelistApis.ts index ca28d2fb..aebc38f0 100644 --- a/src/utils/whitelistApis.ts +++ b/src/utils/whitelistApis.ts @@ -1295,27 +1295,6 @@ export const API_LIST = { 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/discussion/user/uid/:uid': { checksNeeded: [CHECK.ROLE], // tslint:disable-next-line: object-literal-sort-keys @@ -1323,13 +1302,6 @@ export const API_LIST = { 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/discussion/user/:username/posts': { checksNeeded: [CHECK.ROLE], // tslint:disable-next-line: object-literal-sort-keys @@ -1337,13 +1309,6 @@ export const API_LIST = { ROLE.PUBLIC, ], }, - '/proxies/v8/action/framework/v3/category/create': { - checksNeeded: [CHECK.ROLE], - // tslint:disable-next-line: object-literal-sort-keys - ROLE_CHECK: [ - ROLE.PUBLIC, - ], - }, // '/protected/v8/cohorts/course/batch/cert/download/', // '/protected/v8/cohorts/course/batch/cert/issue', // '/protected/v8/cohorts/course/batch/cert/template/add', @@ -1354,13 +1319,6 @@ export const API_LIST = { 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, - ], - }, '/protected/v8/cohorts/course/batch/cert/issue': { checksNeeded: [CHECK.ROLE], // tslint:disable-next-line: object-literal-sort-keys @@ -1368,13 +1326,6 @@ export const API_LIST = { 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, - ], - }, '/protected/v8/cohorts/course/batch/cert/template/add': { checksNeeded: [CHECK.ROLE], // tslint:disable-next-line: object-literal-sort-keys @@ -1382,13 +1333,6 @@ export const API_LIST = { ROLE.PUBLIC, ], }, - '/proxies/v8/action/framework/v3/term/create': { - checksNeeded: [CHECK.ROLE], - // tslint:disable-next-line: object-literal-sort-keys - ROLE_CHECK: [ - ROLE.PUBLIC, - ], - }, }, URL_PATTERN: [ @@ -1578,14 +1522,6 @@ export const API_LIST = { '/proxies/v8/budget/scheme/:orgId/:budgetYear', '/proxies/v8/orghistory/:orgId/:key', '/proxies/v8/discussion/user/uid/:uid', - '/proxies/v8/discussion/user/:username/posts', - '/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', + '/proxies/v8/discussion/user/:username/posts' ], }