Skip to content

Commit 15ad91b

Browse files
authored
add check for handling error in decryption function (#88)
* add check for handling error in decrption function * fix typo
1 parent 20beac4 commit 15ad91b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/api/api.controller.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,20 @@ export class ApiController {
110110
encodedBase64Key === undefined
111111
? CryptoJS.enc.Base64.parse('bla')
112112
: CryptoJS.enc.Base64.parse(encodedBase64Key);
113-
const loginId = this.apiService.decrypt(user.loginId, parsedBase64Key);
114-
const password = this.apiService.decrypt(user.password, parsedBase64Key);
113+
114+
let loginId = '';
115+
try {
116+
loginId = this.apiService.decrypt(user.loginId, parsedBase64Key);
117+
} catch (e) {
118+
console.log(`Problem in decrypting loginId: ${user.loginId}`);
119+
}
120+
121+
let password = '';
122+
try {
123+
password = this.apiService.decrypt(user.password, parsedBase64Key);
124+
} catch (e) {
125+
console.log(`Problem in decrypting password: ${user.password}`);
126+
}
115127

116128
// if we are not able to decrypt, we'll try to authenticate with the original creds
117129
user.loginId = loginId ? loginId : user.loginId;

0 commit comments

Comments
 (0)