mirror of
https://github.com/jambonz/jambonz-webapp.git
synced 2026-07-04 19:21:58 +00:00
Mask API Key (other than last 4 characters)
This commit is contained in:
@@ -37,11 +37,18 @@ const AccountsAddEdit = () => {
|
||||
Authorization: `Bearer ${localStorage.getItem('token')}`,
|
||||
},
|
||||
});
|
||||
const simplifiedApiKeys = results.data.map(a => ({
|
||||
sid: a.api_key_sid,
|
||||
token: a.token,
|
||||
last_used: a.last_used || "Never used",
|
||||
}));
|
||||
const simplifiedApiKeys = results.data.map(a => {
|
||||
const { token } = a;
|
||||
const maskLength = token.length - 4;
|
||||
const maskedPortion = token.substring(0, maskLength).replace(/[a-zA-Z0-9]/g, '*');
|
||||
const revealedPortion = token.substring(maskLength);
|
||||
const maskedToken = `${maskedPortion}${revealedPortion}`;
|
||||
return {
|
||||
sid: a.api_key_sid,
|
||||
token: maskedToken,
|
||||
last_used: a.last_used || "Never used",
|
||||
};
|
||||
});
|
||||
return(simplifiedApiKeys);
|
||||
} catch (err) {
|
||||
if (err.response && err.response.status === 401) {
|
||||
|
||||
Reference in New Issue
Block a user