github.com/justinjmoses/evergreen@v0.0.0-20170530173719-1d50e381ff0d/public/static/js/login.js (about)

     1  mciModule.controller('LoginCtrl', function($scope, $window, $location, mciLoginRestService) {
     2  
     3    $scope.credentials = {};
     4    $scope.errorMessage = '';
     5    $scope.redirect = $location.search().redirect;
     6    $scope.authenticate = function() {
     7      mciLoginRestService.authenticate(
     8          $scope.credentials.username, 
     9          $scope.credentials.password,
    10          {},
    11          {
    12            success: function(data) {
    13              redirect = $scope.redirect || "/";
    14              $window.location.href = decodeURIComponent(redirect);
    15            },
    16            error: function(jqXHR, status, errorThrown) {
    17              $scope.errorMessage = jqXHR;
    18            }
    19          }
    20      );
    21    };
    22  });
    23  
    24  
    25  
    26  
    27  mciModule.controller('LoginModalCtrl', function($scope, $window, mciLoginRestService, $controller) {
    28  
    29    // Inherit from LoginCtrl
    30    $controller('LoginCtrl', {$scope: $scope});
    31  
    32    $scope.openLoginModal = function() {
    33      if ($window.redirect) {
    34        $window.location.href = "/login/redirect";
    35      } else {
    36      var modal = $('#login-modal').modal('show');
    37      $('#username-modal').focus();
    38      }
    39    };
    40  });
    41  
    42  mciModule.directive('loginModal', function() {
    43    return {
    44      restrict: 'E',
    45      replace: true,
    46      templateUrl: '/static/partials/login_modal.html'
    47    };
    48  });