Skip to content
Snippets Groups Projects
Commit 70e27a53 authored by Sandro Weber's avatar Sandro Weber Committed by Viktor Vorobev
Browse files

Merged in bugfix/NRRPLT-8928-ebrains-auth-userinfo-id (pull request #6)

remapped id to preferred_username

* remapped id to preferred_username


Approved-by: Viktor Vorobev
parent a46c7ad9
No related branches found
No related tags found
No related merge requests found
...@@ -32,31 +32,35 @@ export class Identity extends BaseIdentity { ...@@ -32,31 +32,35 @@ export class Identity extends BaseIdentity {
usersList: any[] = []; usersList: any[] = [];
getUniqueIdentifier(token) { getUniqueIdentifier(token) {
return this.getUserInfo('me', token).then(({id}) => id); return this.getUserInfo('me', token).then(({ id }) => id);
} }
async getUserInfo(userId, token) { async getUserInfo(userId, token) {
// remap from collab 2 api to old one // remap from collab 2 api to old one
const response: any = await CollabConnector.instance.getHTTPS(oidcAuthenticator.getUserinfoEndpoint(), token, undefined); const response: any = await CollabConnector.instance.getHTTPS(
const userInfo = JSON.parse(response.body, function(k, v) { oidcAuthenticator.getUserinfoEndpoint(),
if (k === 'name') { token,
this.displayName = v; undefined
} else if (k === 'preferred_username') );
this.username = v; const userInfo = JSON.parse(response.body, function(key, value) {
else if (k === 'mitreid-sub') if (key === 'name') {
this.id = v; this.displayName = value;
else } else if (key === 'preferred_username') {
return v; }); this.username = value;
this.id = value;
} else return value;
});
if (userId !== userInfo.id && userId !== 'me') if (userId !== userInfo.id && userId !== 'me') return {};
return {}; else return userInfo;
else
return userInfo;
} }
async getUserGroups(token) { async getUserGroups(token) {
const response: any = await CollabConnector.instance const response: any = await CollabConnector.instance.getHTTPS(
.getHTTPS(oidcAuthenticator.getUserinfoEndpoint(), token, undefined); oidcAuthenticator.getUserinfoEndpoint(),
token,
undefined
);
const json = JSON.parse(response.body); const json = JSON.parse(response.body);
return json.roles && json.roles.group; return json.roles && json.roles.group;
} }
......
...@@ -1020,8 +1020,6 @@ describe('Collab Storage', () => { ...@@ -1020,8 +1020,6 @@ describe('Collab Storage', () => {
type: 'file' type: 'file'
}; };
console.info(await collabStorage.listFiles(fakeExperiment, fakeToken));
return expect(collabStorage.listFiles(fakeExperiment, fakeToken)) return expect(collabStorage.listFiles(fakeExperiment, fakeToken))
.to.eventually.be.an('array') .to.eventually.be.an('array')
.that.include(expected); .that.include(expected);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment