Browse Source

Fixing issues discovered by cypress tests.

pull/4023/head
mike12345567 5 years ago
parent
commit
f4757aeee1
  1. 5
      packages/auth/src/middleware/authenticated.js
  2. 2
      packages/server/src/api/controllers/dev.js
  3. 7
      packages/worker/src/api/controllers/admin/configs.js
  4. 3
      packages/worker/src/api/controllers/admin/users.js

5
packages/auth/src/middleware/authenticated.js

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

2
packages/server/src/api/controllers/dev.js

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

7
packages/worker/src/api/controllers/admin/configs.js

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

3
packages/worker/src/api/controllers/admin/users.js

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

Loading…
Cancel
Save