Hi Everyone I created a RESTful API with authentication with token (Rails 4 + Devise), Also I manage the CORS implementation with a gem(rack-cors) but now I would like use the API with angular.js
For this I do this:
var app = angular.module('models');
app.factory('Session',['$resource',function($resource){
var Session = $resource(
'http://api.creositios.dev/sessions/:id',
{},
{
create: { method: 'POST'},
delete: { method: 'DELETE', params: { id: '@id'} }
}
);
return Session;
}]);
And this is my controller
app = angular.module('controllers');
app.controller('SessionCtrl',['$scope','Session',function($scope,Session){
$scope.new_session = function(){
$scope.session = Session.create({email: '[email protected]', password: '12345678'});
};
}]);
So far I have not problem with the implementation. My problem is have not idea how to management the Token that return my factory.
What is the good practices for managment the token of user with angular.js and validates the user in the differents controllers in angular.js?
This is my first app with authentication with token. Advice is very appreciate!.