Skip to content

Commit

Permalink
Merge pull request #171 from uwrit/header-name-fix
Browse files Browse the repository at this point in the history
Header name fix
  • Loading branch information
ndobb authored Jun 6, 2019
2 parents 33bdfc2 + bc7dd9b commit 582a765
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/server/API/API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<TieredCompilation>true</TieredCompilation>
<ReleaseVersion>3.1.1</ReleaseVersion>
<ReleaseVersion>3.1.3</ReleaseVersion>
</PropertyGroup>
<PropertyGroup>
<LangVersion>latest</LangVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/ui-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ui-client",
"version": "3.1.1",
"version": "3.1.3",
"private": true,
"dependencies": {
"@types/d3-format": "^1.3.0",
Expand Down
15 changes: 11 additions & 4 deletions src/ui-client/src/actions/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ export const getIdToken = () => {
dispatch(receiveAuthConfig(config));

// Get user id token
getUserTokenAndContext(config).then((token) => {
dispatch(setRouteConfig(getRoutes(config, token)));
dispatch(receiveIdToken(token));
});
getUserTokenAndContext(config)
.then((token) => {
dispatch(setRouteConfig(getRoutes(config, token)));
dispatch(receiveIdToken(token));
})
.catch((reason) => {
attemptLoginRetryIfPossible();
console.log(reason);
const message = "Hmm... The Leaf server doesn't seem to be responding. Please contact your Leaf administrator.";
dispatch(failureIdToken(message));
});
}, error => {
attemptLoginRetryIfPossible();
console.log(error);
Expand Down
2 changes: 1 addition & 1 deletion src/ui-client/src/containers/Header/Header.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}

.header-content-side {
width: 30%;
width: 35%;
}

.header-content-side-right {
Expand Down
1 change: 1 addition & 0 deletions src/ui-client/src/models/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export interface UserContext {
name: string;
rawDecoded: DecodedIdToken;
roles: string[];
scope: string;
token: string;
version: string;
}
Expand Down
11 changes: 10 additions & 1 deletion src/ui-client/src/services/authApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ const getIdTokenKey = (config: AuthConfig) => {
const decodeToken = (token: string): UserContext => {
const decoded = jwt_decode(token) as DecodedIdToken;
const roles = decoded['http://schemas.microsoft.com/ws/2008/06/identity/claims/role'];
const name = decoded['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name'];
const fullname = decoded['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name'];
const nameSplit = fullname.split('@');
let name = fullname;
let scope = '';

if (nameSplit.length === 2) {
name = nameSplit[0];
scope = nameSplit[1];
}

const ctx: UserContext = {
expirationDate: new Date(decoded.exp * 1000),
Expand All @@ -37,6 +45,7 @@ const decodeToken = (token: string): UserContext => {
name,
rawDecoded: decoded,
roles,
scope,
token,
version: decoded['leaf-version']
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui-client/src/services/sessionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const attemptLoginRetryIfPossible = () => {
const retry = sessionStorage.getItem(key);
if (!retry) {
sessionStorage.setItem(key, 'X');
window.location = window.location;
window.location.reload(true);
} else {
sessionStorage.removeItem(key);
}
Expand Down

0 comments on commit 582a765

Please sign in to comment.