{"action":"closed","issue":{"url":"https://api.github.com/repos/linnovate/mean/issues/795","labels_url":"https://api.github.com/repos/linnovate/mean/issues/795/labels{/name}","comments_url":"https://api.github.com/repos/linnovate/mean/issues/795/comments","events_url":"https://api.github.com/repos/linnovate/mean/issues/795/events","html_url":"https://github.com/linnovate/mean/issues/795","id":42901347,"number":795,"title":"HowTo: Redirect after login","user":{"login":"MichaelJCole","id":1504790,"avatar_url":"https://avatars.githubusercontent.com/u/1504790?v=3","gravatar_id":"","url":"https://api.github.com/users/MichaelJCole","html_url":"https://github.com/MichaelJCole","followers_url":"https://api.github.com/users/MichaelJCole/followers","following_url":"https://api.github.com/users/MichaelJCole/following{/other_user}","gists_url":"https://api.github.com/users/MichaelJCole/gists{/gist_id}","starred_url":"https://api.github.com/users/MichaelJCole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MichaelJCole/subscriptions","organizations_url":"https://api.github.com/users/MichaelJCole/orgs","repos_url":"https://api.github.com/users/MichaelJCole/repos","events_url":"https://api.github.com/users/MichaelJCole/events{/privacy}","received_events_url":"https://api.github.com/users/MichaelJCole/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2014-09-16T16:17:13Z","updated_at":"2015-11-07T23:10:39Z","closed_at":"2015-11-07T23:10:39Z","body":"Are the user and system modules meant to be customized in a MEAN.js app?\r\n\r\nI found myself wanting to redirect users after login to a new route ('/dashboard').\r\n\r\nTo do this I was customizing the users package.  That's the simplest way to do it, or should it be a config option for the module?\r\n\r\nThanks!\r\n\r\nMike\r\n\r\n```\r\n'use strict';\r\nangular.module('mean.users')\r\n  .controller('LoginCtrl', ['$scope', '$rootScope', '$http', '$location',\r\n    function($scope, $rootScope, $http, $location) {\r\n      // This object will be filled by the form\r\n      $scope.user = {};\r\n\r\n      // Register the login() function\r\n      $scope.login = function() {\r\n        $http.post('/login', {\r\n          email: $scope.user.email,\r\n          password: $scope.user.password\r\n        })\r\n          .success(function(response) {\r\n            // authentication OK\r\n            $scope.loginError = 0;\r\n            $rootScope.user = response.user;\r\n            $rootScope.$emit('loggedin');\r\n            if (response.redirect) {\r\n              if (window.location.href === response.redirect) {\r\n                //This is so an admin user will get full admin page\r\n                window.location.reload();\r\n              } else {\r\n                window.location = response.redirect;\r\n              }\r\n            } else {\r\n              $location.url('/dashboard/example');\r\n            }\r\n          })\r\n          .error(function() {\r\n            $scope.loginerror = 'Authentication failed.';\r\n          });\r\n      };\r\n    }\r\n  ])\r\n```\r\n"}}