'use strict';

const ctrlFactory = require('restitute').controller;
const abuseFilter = require('../../modules/abusefilter');


/**
 * A POST on anonymous/formlogin
 * login with local strategie or ldap strategie
 */
function createController() {
    // TODO: change to /rest/annonymous/formlogin
    ctrlFactory.create.call(this, '/rest/login');
    let controller = this;
    let gt = controller.req.app.utility.gettext;
    let workflow = controller.req.app.utility.workflow(controller.req, controller.res);


    function validate() {
        // TODO: rework this as Promise
        if (workflow.needRequiredFields(['username', 'password'])) {
            return workflow.emit('response');
        }

        abuseFilter(controller.req);
    }

    this.controllerAction = function() {

        validate();
    };
}
createController.prototype = new ctrlFactory.create();


exports = module.exports = {
    create: createController
};

@@ -336,24 +336,25 @@
 st/login');%0A
+%0A
     let cont
@@ -372,21 +372,18 @@
 is;%0A
+%0A
     
-let gt = 
+this.
 cont
@@ -392,34 +392,35 @@
 ller
-.req.app.utility.gettext;%0A
+Action = function() %7B%0A%0A    
     
@@ -505,16 +505,20 @@
 res);%0A%0A%0A
+    
     func
@@ -539,24 +539,28 @@
 ) %7B%0A        
+    
 // TODO: rew
@@ -579,16 +579,20 @@
 Promise%0A
+    
         
@@ -664,16 +664,20 @@
         
+    
 return w
@@ -702,16 +702,20 @@
 onse');%0A
+    
         
@@ -725,16 +725,20 @@
         
+    
 abuseFil
@@ -766,51 +766,14 @@
     
-%7D%0A%0A
     
-this.controllerAction = function() %7B
+%7D%0A
 %0A%0A  

Fix app start