Authentication and Authorization in AngularJS
<p>I am following a tutorial from this blog</p>

<p><a href="https://medium.com/opinionated-angularjs/techniques-for-authentication-in-angularjs-applications-7bbf0346acec#.4st6f3te5" rel="nofollow noreferrer">https://medium.com/opinionated-angularjs/techniques-for-authentication-in-angularjs-applications-7bbf0346acec#.4st6f3te5</a></p>

<p>for Authentication and Authorization in angualrJS</p>

<p>Also trying to fallow some implementation in Stackoverflow
on this link
<a href="https://stackoverflow.com/questions/33357412/injectormodulerr-authentication-in-angularjs-applications">$injector:modulerr : authentication in AngularJS applications</a></p>

<p>I keep getting this error
$scope.setCurrentUser is not a function
which is coming from the loginController </p>

<p>Can someone help please?</p>

<ol>
<li>this the AuthService</li>
</ol>

<blockquote>
  <p>pmaster.factory('AuthService', ['$http', 'Session', function ($http,
  Session) {
      var authService = {};</p>

<pre><code>authService.login = function (credentials)
{
    return $http.get('/api/userLogin/' + credentials).then(function (data)
    {  
      // this is the date coming from the Server          //[{"sessionID":"aendypagaw5ytojlxjcvjgyo","userID":"ljanneh1","Role":"superAdmin"}]
        Session.create(data.sessionID, data.userID, data.Role);
        return data
      });
};

authService.isAuthenticated = function()
{
    return !!Session.userId;
};

authService.isAuthorized = function (authorizedRoles) {
    if (!angular.isArray(authorizedRoles)) {
        authorizedRoles = [authorizedRoles];
    }
    return (authService.isAuthenticated() &amp;&amp;
      authorizedRoles.indexOf(Session.userRole) !== -1);
};

return authService; }]);
</code></pre>
</blockquote>

<p>this is the login control</p>

<blockquote>
  <p>pmaster.controller('loginController', ['$scope', '$location',
  '$rootScope', 'AUTH_EVENTS', 'AuthService',
      function ($scope, $location, $rootScope, AUTH_EVENTS, AuthService)
      {</p>

<pre><code>    $rootScope.menuHide = true;
    $rootScope.sideHide = true;


    $scope.Login = function()
    {
        $scope.loading = true;

        var credentials =
        {
            'username': $scope.username,
            'password': $scope.password

        }

        var obj = credentials.username + "-" + credentials.password;

        AuthService.login(obj).then(function (data)
        {
            console.log(data);
            $rootScope.$broadcast(AUTH_EVENTS.loginSuccess);

            //$scope.setCurrentUser = function (data)
            //{
            //    $rootScope.$emit("setUserRoles", data);
            //}
             $scope.setCurrentUser(data);
            $location.path('/addBank');
            $scope.loading = false;
        }, function (error) {
            $rootScope.$broadcast(AUTH_EVENTS.loginFailed);
            alert("Bad");
            $scope.loading = false;
        });
    }
}]);
</code></pre>
</blockquote>