             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) =>

                    console.log err
                    @sendError res, "Server error occured.", 500
                else
                    req.logIn user, {}, =>
                        @sendSuccess res, "Register succeeds."

        user =
            email: email

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

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

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