             else
                 req.logIn user, {}, answer
 
+        authenticator(req, res)
+
+
+    loginAction: (req, res) =>
         req.body.username = "owner"
-        authenticator(req, res)
+        @authenticate(req, res)
 
     # Clear authentication credentials from session for current user.
     logoutAction: (req, res) =>

    authenticatedAction: (req, res) =>
        res.send success: req.isAuthenticated()

    # Check user credentials and keep user authentication through session.
    loginAction: (req, res) =>
        answer = (err) =>
            if err
                @sendError res, "Login failed"
            else
                @sendSuccess res, "Login succeeds"

        authenticator = passport.authenticate 'local', (err, user) =>
            if err

        
        res.send
            success: true
            msg: "Log out succeeded."

    # Create user with given credentials
    registerAction: (req, res) =>
