1
0
Fork 0
mirror of synced 2024-06-30 20:10:54 +12:00

Fixing issues discovered by cypress tests.

This commit is contained in:
mike12345567 2021-06-21 18:37:14 +01:00
parent 7039b8d7eb
commit f4757aeee1
4 changed files with 12 additions and 5 deletions

View file

@ -50,10 +50,9 @@ module.exports = (noAuthPatterns = [], opts) => {
if (authCookie) {
try {
const db = database.getDB(StaticDatabases.GLOBAL.name)
const foundUser = await db.get(authCookie.userId)
delete foundUser.password
user = await db.get(authCookie.userId)
delete user.password
authenticated = true
user = foundUser
} catch (err) {
// remove the cookie as the use does not exist anymore
clearCookie(ctx, Cookies.Auth)

View file

@ -14,7 +14,7 @@ async function redirect(ctx, method) {
request(ctx, {
method,
body: ctx.request.body,
})
}, true)
)
if (response.status !== 200) {
ctx.throw(response.status, response.statusText)

View file

@ -102,9 +102,14 @@ exports.publicSettings = async function (ctx) {
const db = new CouchDB(GLOBAL_DB)
try {
// Find the config with the most granular scope based on context
ctx.body = await getScopedFullConfig(db, {
const config = await getScopedFullConfig(db, {
type: Configs.SETTINGS,
})
if (!config) {
ctx.body = {}
} else {
ctx.body = config
}
} catch (err) {
ctx.throw(err.status, err)
}

View file

@ -130,6 +130,9 @@ exports.removeAppRole = async ctx => {
}
exports.getSelf = async ctx => {
if (!ctx.user) {
ctx.throw(403, "User not logged in")
}
ctx.params = {
id: ctx.user._id,
}