update libflitter/flap & run migrations
This commit is contained in:
parent
d25b54da88
commit
33aa97ee49
@ -3,7 +3,8 @@
|
||||
* -------------------------------------------------------------
|
||||
* Put some description here!
|
||||
*/
|
||||
class Debug {
|
||||
const Middleware = require('libflitter/middleware/Middleware')
|
||||
class Debug extends Middleware {
|
||||
|
||||
/*
|
||||
* Run the middleware test.
|
||||
|
@ -6,7 +6,8 @@
|
||||
* the '/' route is accessed. It can be injected in routes globally using
|
||||
* the global mw() function.
|
||||
*/
|
||||
class HomeLogger {
|
||||
const Middleware = require('libflitter/middleware/Middleware')
|
||||
class HomeLogger extends Middleware {
|
||||
|
||||
/*
|
||||
* Run the middleware test.
|
||||
|
@ -8,7 +8,8 @@
|
||||
*
|
||||
* @class
|
||||
*/
|
||||
class Permission {
|
||||
const Middleware = require('libflitter/middleware/Middleware')
|
||||
class Permission extends Middleware {
|
||||
|
||||
/**
|
||||
* Run the middleware's check. If an authenticated session exists and the user has the specified permission,
|
||||
@ -23,23 +24,25 @@ class Permission {
|
||||
if (req.session && req.session.auth && (req.session.auth.authenticated === true || req.session.auth.user)) {
|
||||
if (req.session.auth.user.permissions && req.session.auth.user.permissions.includes(permission)) {
|
||||
next()
|
||||
}
|
||||
else if ( req.session.auth.user.role ){
|
||||
} else if (req.session.auth.user.role) {
|
||||
const Role = _flitter.model('auth:Role')
|
||||
const role = await Role.findOne({name: req.session.auth.user.role})
|
||||
const role = await Role.findOne({
|
||||
name: req.session.auth.user.role
|
||||
})
|
||||
|
||||
if (role.permissions.includes(permission)) {
|
||||
next()
|
||||
} else {
|
||||
return _flitter.error(res, 401, {
|
||||
reason: 'Insufficient user permissions.'
|
||||
})
|
||||
}
|
||||
else {
|
||||
return _flitter.error(res, 401, {reason: 'Insufficient user permissions.'})
|
||||
} else {
|
||||
return _flitter.error(res, 401, {
|
||||
reason: 'Insufficient user permissions.'
|
||||
})
|
||||
}
|
||||
}
|
||||
else {
|
||||
return _flitter.error(res, 401, {reason: 'Insufficient user permissions.'})
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
req.session.destination = req.originalUrl
|
||||
return res.redirect('/auth/login')
|
||||
}
|
||||
|
@ -8,7 +8,8 @@
|
||||
*
|
||||
* @class
|
||||
*/
|
||||
class RequireAuth {
|
||||
const Middleware = require('libflitter/middleware/Middleware')
|
||||
class RequireAuth extends Middleware {
|
||||
|
||||
/**
|
||||
* Run the middleware's check. If an authenticated session exists, let the request continue.
|
||||
@ -24,8 +25,7 @@ class RequireAuth {
|
||||
* Call the next function in the stack.
|
||||
*/
|
||||
next()
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
req.session.destination = req.originalUrl
|
||||
return res.redirect('/auth/login')
|
||||
}
|
||||
|
@ -8,7 +8,8 @@
|
||||
*
|
||||
* @class
|
||||
*/
|
||||
class RequireGuest {
|
||||
const Middleware = require('libflitter/middleware/Middleware')
|
||||
class RequireGuest extends Middleware {
|
||||
|
||||
/**
|
||||
* Run the middleware test. If an authenticated session exists, redirect the user to an error page.
|
||||
|
@ -8,7 +8,8 @@
|
||||
*
|
||||
* @class
|
||||
*/
|
||||
class Role {
|
||||
const Middleware = require('libflitter/middleware/Middleware')
|
||||
class Role extends Middleware {
|
||||
|
||||
/**
|
||||
* Run the middleware's check. If an authenticated session exists and the user has the specified role,
|
||||
@ -23,12 +24,12 @@ class Role {
|
||||
if (req.session && req.session.auth && (req.session.auth.authenticated === true || req.session.auth.user)) {
|
||||
if (req.session.auth.user.role && req.session.auth.user.role === role) {
|
||||
next()
|
||||
} else {
|
||||
return _flitter.error(res, 401, {
|
||||
reason: 'Insufficient user permissions.'
|
||||
})
|
||||
}
|
||||
else {
|
||||
return _flitter.error(res, 401, {reason: 'Insufficient user permissions.'})
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
req.session.destination = req.originalUrl
|
||||
return res.redirect('/auth/login')
|
||||
}
|
||||
|
@ -3,7 +3,8 @@
|
||||
* -------------------------------------------------------------
|
||||
* Put some description here!
|
||||
*/
|
||||
class Invite {
|
||||
const Middleware = require('libflitter/middleware/Middleware')
|
||||
class Invite extends Middleware {
|
||||
|
||||
/*
|
||||
* Run the middleware test.
|
||||
|
@ -23,5 +23,10 @@
|
||||
"id": 1565741502,
|
||||
"name": "convert_to_new_model_schema_definitions",
|
||||
"migratedOn": "2019-08-15T14:58:30.109Z"
|
||||
},
|
||||
{
|
||||
"id": 1565925593,
|
||||
"name": "make_existing_middleware_extend_base_class",
|
||||
"migratedOn": "2019-08-16T14:49:39.934Z"
|
||||
}
|
||||
]
|
||||
|
@ -18,11 +18,11 @@
|
||||
"dependencies": {
|
||||
"flitter-auth": "^0.4.0",
|
||||
"flitter-cli": "^0.10.0",
|
||||
"flitter-flap": "^0.3.1",
|
||||
"flitter-flap": "^0.4.0",
|
||||
"flitter-forms": "^0.7.2",
|
||||
"flitter-upload": "^0.7.6",
|
||||
"js-beautify": "^1.10.2",
|
||||
"libflitter": "^0.28.0",
|
||||
"libflitter": "^0.29.3",
|
||||
"stringify-object": "^3.3.0"
|
||||
}
|
||||
}
|
||||
|
16
yarn.lock
16
yarn.lock
@ -869,10 +869,10 @@ flitter-cli@^0.10.0:
|
||||
mkdirp "^0.5.1"
|
||||
nesh "^1.7.0"
|
||||
|
||||
flitter-flap@^0.3.1:
|
||||
version "0.3.1"
|
||||
resolved "https://registry.yarnpkg.com/flitter-flap/-/flitter-flap-0.3.1.tgz#12dca0f43a6bfefd89b9e461b1eb1f1e7db18cd9"
|
||||
integrity sha512-I22gvdK3cKCnQZGVXwtbgtWTkCakhZGs46K5g+UcoKYurHhjo+9+rqsPGZbYzIcFIhwPJTyv3Ve5aZprDz22WQ==
|
||||
flitter-flap@^0.4.0:
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/flitter-flap/-/flitter-flap-0.4.0.tgz#ab1cdfc5b9ffe0b5b9fe2e3a8bdc87e9aac82c0e"
|
||||
integrity sha512-1pfGAckDJ7RZIK6qheAz2dwA4PV/03Z7rPhhVuDqZbuemtiozLgDLPQXzGwSLQESWNuG6CBg3KMEd0CPppB1/Q==
|
||||
dependencies:
|
||||
del "^4.1.0"
|
||||
js-beautify "^1.10.2"
|
||||
@ -1274,10 +1274,10 @@ leven@^1.0.2:
|
||||
resolved "https://registry.yarnpkg.com/leven/-/leven-1.0.2.tgz#9144b6eebca5f1d0680169f1a6770dcea60b75c3"
|
||||
integrity sha1-kUS27ryl8dBoAWnxpncNzqYLdcM=
|
||||
|
||||
libflitter@^0.28.0:
|
||||
version "0.28.0"
|
||||
resolved "https://registry.yarnpkg.com/libflitter/-/libflitter-0.28.0.tgz#c132dfb74e3a3e6148e924ce5ab9fc6094a6625c"
|
||||
integrity sha512-s7m0odIm96QcuycJ4GUyu4Ub6zooCtXnIRjXccAgkKMMkz1I84qT0+DO6tRiSBPlnxA9lXpDjrAzyY0Z5OpQmw==
|
||||
libflitter@^0.29.3:
|
||||
version "0.29.3"
|
||||
resolved "https://registry.yarnpkg.com/libflitter/-/libflitter-0.29.3.tgz#b3daaac4405599b51f943fd1331a576db6bb9a2d"
|
||||
integrity sha512-3W6Mack+U5s7YAN6ItIClI+Q9gAqeOlioHleU1LyilFAwmZxth098mRd+pV0ZLGomtzIeyxJcmP9bYg7RC62pg==
|
||||
dependencies:
|
||||
busboy-body-parser "^0.3.2"
|
||||
connect-mongodb-session "^2.2.0"
|
||||
|
Loading…
Reference in New Issue
Block a user