From 0178fd719d3fecf057f426253a872f0b4108ffab Mon Sep 17 00:00:00 2001 From: venkatkadiveti Date: Tue, 21 Dec 2021 10:44:42 +0530 Subject: [PATCH 1/2] Issue #SB-27131 fix: Log api error telemetry event when the user having not allowed special characters present in the username --- library.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library.js b/library.js index 1c75783..ffb848b 100644 --- a/library.js +++ b/library.js @@ -98,13 +98,12 @@ rolesEnabled: settings.rolesClaim && settings.rolesClaim.length !== 0, isAdmin: false, }, async (err, user) => { - const userSlug = await User.getUserField(user.uid, 'userslug'); - console.log("'SB OIDC Token: userSlug-", userSlug); console.log('SB OIDC Token: request original url:', req.originalUrl); console.log('SB OIDC Token: request path url:', req.path); console.log('SB OIDC Token: request url:', req.url); console.log('SB OIDC Token: request protocol url:', req.protocol); if(err && err === 'UserExists'){ + const userSlug = await User.getUserField(user.uid, 'userslug'); response.responseCode = "CLIENT_ERROR"; response.responseCode = "400"; response.params.status = "unsuccessful"; @@ -120,6 +119,7 @@ console.log("SB OIDC Token: Error While checkig the tokens", error) } }else if(user){ + const userSlug = await User.getUserField(user.uid, 'userslug'); response.responseCode = "OK" response.params.status = "successful"; response.params.msg = "User created successful"; @@ -136,9 +136,11 @@ }else{ console.log("SB OIDC: Error Log for ", req.originalUrl) response.responseCode = "SERVER_ERROR" - response.responseCode = "400" + response.responseCode = "400"; + response.params.error = err.message; console.log(err); - res.json(response); + res.status(400); + res.send(response); } }); From e6846357d6fd4d36a93ea6313b3dfb9234f55fea Mon Sep 17 00:00:00 2001 From: venkatkadiveti Date: Tue, 21 Dec 2021 10:45:43 +0530 Subject: [PATCH 2/2] Issue #SB-27131 fix: Log api error telemetry event when the user having not allowed special characters present in the username --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 24a10ec..b270304 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodebb-plugin-sunbird-oidc", - "version": "1.0.16", + "version": "1.0.17", "description": "Authenticate to Sunbird identity provider.", "main": "library.js", "repository": {