[mod] refactoring, extract functions

This commit is contained in:
Laurent Peuch 2018-06-30 23:32:54 +02:00
parent 903dd9f506
commit 8a06430026

View file

@ -8,27 +8,26 @@
* Filters * Filters
* *
*/ */
app.before(/domains\/add/, function (req){
function prefetchDomains(req) {
// Preload domains list. // Preload domains list.
req.params.domains = []; req.params.domains = [];
req.api('/domains', function(data) { req.api('/domains', function(data) {
req.params.domains = data.domains; req.params.domains = data.domains;
}); });
}); }
app.before(/apps\/install\//, function (req){
// Preload domains list. function prefetchUsers(req){
req.params.domains = [];
req.api('/domains', function(data) {
req.params.domains = data.domains;
});
});
app.before(/apps\/install\//, function (req){
// Preload users lists. // Preload users lists.
req.params.users = []; req.params.users = [];
req.api('/users', function(data) { req.api('/users', function(data) {
req.params.users = data.users; req.params.users = data.users;
}); });
}); }
app.before(/domains\/add/, prefetchDomains);
app.before(/apps\/install\//, prefetchDomains);
app.before(/apps\/install\//, prefetchUsers);
app.before({except: {path: ['#/logout', '#/login', '#/postinstall', '#/postinstall/domain', '#/postinstall/password']}}, function (req) { app.before({except: {path: ['#/logout', '#/login', '#/postinstall', '#/postinstall/domain', '#/postinstall/password']}}, function (req) {