1
0
Fork 0
mirror of synced 2024-06-26 18:10:51 +12:00

tests passing...

This commit is contained in:
michael shanks 2019-06-21 14:00:24 +01:00
parent c2d444f808
commit a782e124e6
5 changed files with 23 additions and 10 deletions

@ -1 +1 @@
Subproject commit 29318b29d35ac8d8bfb137a5e739a308e01c1829
Subproject commit b372ad7403fa12f92670ef38e7576bc5795006e9

View file

@ -53,7 +53,7 @@ const deleteFolder = root => async (path) =>
const readableFileStream = root => async path =>
fs.createReadStream(
join(root, path), "utf8"
join(root, path)
);
const writableFileStream = root => path =>

View file

@ -69,7 +69,11 @@ module.exports = (config, app) => {
pathParts[1],
ctx.sessionId);
await next();
if(ctx.instance === null) {
ctx.response.status = StatusCodes.UNAUTHORIZED;
} else {
await next();
}
})
.post("/:appname/api/changeMyPassword", async (ctx) => {
await ctx.instance.authApi.changeMyPassword(

View file

@ -88,7 +88,7 @@ module.exports = (app) => {
await app.get("/_master/api/users/")
.set("cookie", newUserCookie)
.expect(statusCodes.FORBIDDEN);
.expect(statusCodes.UNAUTHORIZED);
await app.post("/_master/api/authenticate", {
username: testUserName,

View file

@ -115,15 +115,23 @@ module.exports = async (config) => {
const getInstanceApiForSession = async (appname, sessionId) => {
if(isMaster(appname)) {
const customId = bb.recordApi.customId("mastersession", sessionId);
const session = await bb.recordApi.load(`/sessions/${customId}`);
return await getApisForSession(masterDatastore, session);
try {
const session = await bb.recordApi.load(`/sessions/${customId}`);
return await getApisForSession(masterDatastore, session);
} catch(_) {
return null;
}
}
else {
const app = await getApplication(appname);
const customId = bb.recordApi.customId("session", sessionId);
const session = await bb.recordApi.load(`/applications/${app.id}/sessions/${customId}`);
const instanceDatastore = getInstanceDatastore(session.instanceDatastoreConfig)
return await getApisForSession(instanceDatastore, session);
try {
const session = await bb.recordApi.load(`/applications/${app.id}/sessions/${customId}`);
const instanceDatastore = getInstanceDatastore(session.instanceDatastoreConfig)
return await getApisForSession(instanceDatastore, session);
} catch(_) {
return null;
}
}
};
@ -162,7 +170,8 @@ module.exports = async (config) => {
"/mastersessions_by_user",
{
rangeStartParams:{username},
rangeEndParams:{username}
rangeEndParams:{username},
searchPhrase:`username:${username}`
}
);