From 4c6b015d5ab563146210dcc894c17c71392a81a6 Mon Sep 17 00:00:00 2001
From: priyanka-TL <priyankapratheepan@gmail.com>
Date: Tue, 29 Apr 2025 16:25:49 +0530
Subject: [PATCH] scp update

---
 .../constants/common.js                       | 10 +----
 .../controllers/scp.js                        | 39 +++++++++----------
 2 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/sunbird-self-creation-portal/constants/common.js b/sunbird-self-creation-portal/constants/common.js
index 6f08648c..9336dba5 100644
--- a/sunbird-self-creation-portal/constants/common.js
+++ b/sunbird-self-creation-portal/constants/common.js
@@ -6,15 +6,7 @@
  */
 
 module.exports = {
-	PROJECT_STATUS_PUBLISHED: 'published',
-	PROJECT_PROJECTION_FIELDS: ['_id', 'title', 'createdBy', 'createdAt', 'description'],
-	RESOURCE_TYPE_PROJECT: 'projects',
-	PROJECT_TRANSFORM_KEYS: {
-		_id: 'id',
-		createdAt: 'created_at',
-		createdBy: 'created_by',
-	},
-	AUTH_TOKEN_KEY: 'X-auth-token',
+	AUTH_TOKEN_KEY: 'x-authenticated-user-token',
 	HEADER_CONTENT_TYPE: 'content-type',
 	INTERNAL_ACCESS_TOKEN: 'internal-access-token',
 }
diff --git a/sunbird-self-creation-portal/controllers/scp.js b/sunbird-self-creation-portal/controllers/scp.js
index 0d4604c0..f87eed83 100644
--- a/sunbird-self-creation-portal/controllers/scp.js
+++ b/sunbird-self-creation-portal/controllers/scp.js
@@ -346,12 +346,12 @@ const accountList = async (req, res, selectedConfig) => {
 			body.request.filters.id = userIds
 		}
 
-		if (req.query.organisation_id) {
-			body.request.filters['organisations.organisationId'] = req.query.organisation_id
+		if (req.query.organization_id) {
+			body.request.filters['organisations.organisationId'] = req.query.organization_id
 		}
 
-		if (req.query.organisation_code) {
-			body.request.filters['organisations.organisationId'] = req.query.organisation_code
+		if (req.query.organization_code) {
+			body.request.filters['organisations.organisationId'] = req.query.organization_code
 		}
 
 		if (req.query.type && req.query.type != 'all') {
@@ -362,11 +362,6 @@ const accountList = async (req, res, selectedConfig) => {
 			body.request['limit'] = parseInt(req.query.limit)
 		}
 
-		if (process.env.DEBUG_MODE == 'true') {
-			console.log('------- ================ -------', req.body)
-			console.log(body, 'Req body')
-		}
-
 		// Format token removes "Bearer " if present at the start
 		const authToken = req.headers['x-auth-token'] || ''
 		const cleanToken = authToken.replace(/^bearer\s+/i, '')
@@ -376,8 +371,13 @@ const accountList = async (req, res, selectedConfig) => {
 			Authorization: `Bearer ${process.env.SUNBIRD_BEARER_TOKEN}`, // Authorization token from environment variables
 			'x-authenticated-user-token': cleanToken,
 		})
-		console.log(userSearchResponse, 'userSearchResponse')
-		console.log(cleanToken, body, 'Req body')
+
+		if (process.env.DEBUG_MODE == 'true') {
+			console.log('------- ================ -------', req.body)
+			console.log(body, 'Req body---')
+			console.log(userSearchResponse, 'userSearchResponse')
+			console.log(cleanToken, 'Token')
+		}
 
 		if (userSearchResponse?.responseCode != 'OK') {
 			throw new Error('User Search Failed')
@@ -426,11 +426,6 @@ const organizationList = async (req, res, selectedConfig) => {
 			body.request['limit'] = parseInt(req.query.limit)
 		}
 
-		if (process.env.DEBUG_MODE == 'true') {
-			console.log('------- ================ -------', req.body)
-			console.log(body, 'Req body')
-		}
-
 		// Format token removes "Bearer " if present at the start
 		const authToken = req.headers['x-auth-token'] || ''
 		const cleanToken = authToken.replace(/^bearer\s+/i, '')
@@ -440,18 +435,21 @@ const organizationList = async (req, res, selectedConfig) => {
 			Authorization: `Bearer ${process.env.SUNBIRD_BEARER_TOKEN}`, // Authorization token from environment variables
 			'x-authenticated-user-token': cleanToken,
 		})
-		console.log(orgSearchResponse, 'orgSearchResponse')
-		console.log(cleanToken, body, 'Req body')
+
+		if (process.env.DEBUG_MODE == 'true') {
+			console.log('------- ================ -------', req.body)
+			console.log(body, 'Req body')
+			console.log(orgSearchResponse, 'orgSearchResponse')
+			console.log(cleanToken, body, 'Req body')
+		}
 
 		if (orgSearchResponse?.responseCode != 'OK') {
 			throw new Error('User Search Failed')
 		}
 
 		let data = processOrgSearchResponse(orgSearchResponse.result.response.content) || []
-		// return res.json(orgSearchResponse)
 		return res.json({ result: data?.result })
 	} catch (error) {
-		console.log(error, 'error')
 		if (process.env.DEBUG_MODE == 'true') {
 			console.error('Error fetching user details:', error)
 		}
@@ -465,7 +463,6 @@ const processOrgSearchResponse = (content) => {
 	}
 	return {
 		result: content.map((org) => {
-			console.log(org, 'org')
 			return {
 				id: org.id,
 				name: org?.orgName,
