Skip to content

Commit

Permalink
#0 - changed the token that is copied
Browse files Browse the repository at this point in the history
  • Loading branch information
petmongrels committed Jan 4, 2025
1 parent 913cb0e commit a04d819
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/adminApp/react-admin-config/LogoutButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ const LogoutButton = ({ doLogout, username, onChangePassword = _.noop, lastSessi
<ExitIcon /> Logout
</MenuItem>
{lastSessionTimeMillis > 0 && (
<span style={styles.lastLoginDate}>
Last login: {moment(lastSessionTimeMillis).format("MMM Do YYYY h:mm:ss a")}
</span>
<span style={styles.lastLoginDate}>Last login: {moment(lastSessionTimeMillis).format("MMM Do YYYY h:mm:ss a")}</span>
)}
{ApplicationContext.isDevEnv() && (
<MenuItem
onClick={() => {
navigator.clipboard.writeText(httpClient.getAuthToken());
navigator.clipboard.writeText(httpClient.getIdToken());
}}
>
<LockIcon /> Copy Token
Expand Down
10 changes: 10 additions & 0 deletions src/common/utils/httpClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ class HttpClient {
return localStorage.getItem(IdpDetails.AuthTokenName);
}

getIdToken() {
const keys = Object.keys(localStorage);
for (let i = 0; i < keys.length; i++) {
if (keys[i].endsWith("idToken")) {
return localStorage.getItem(keys[i]);
}
}
return null;
}

async setHeaders(options) {
if (!options.headers) options.headers = new Headers({ Accept: "application/json" });
if (!options.headers.has("Content-Type") && !(options.body && options.body instanceof FormData)) {
Expand Down

0 comments on commit a04d819

Please sign in to comment.