concretesolutions / ng-security

A security module for AngularJS.
MIT License
31 stars 4 forks source link

Custom API response #3

Closed agualbbus closed 8 years ago

agualbbus commented 9 years ago

How can I set up a different response API? for example:

{
  "id": "55eb55d635313400120000fd"
}
mondaini commented 9 years ago

+1 :)

ghost commented 8 years ago

You make use manual login method:

angular
  .module('myApp')
  .controller(['$scope', '$http', '$security', function ($scope, $http, $security) {
    $scope.username = 'admin';
    $scope.password = 'admin';
    $scope.authenticate = function () {
      $http.post('/api/auth', {
        username: $scope.username,
        password: $scope.password
      }).success(function (data) {
        $security.login(data.id);
      });
    }
  }]);