javascript - AngularJS and REST resources naming wondering -


so in angular js app in service called 'authservice' have following resources:

var userarealogin = $resource('/api/user_area/login'); var userareasignup = $resource('/api/user_area/signup'); var session = $resource('/api/user_area/getsession'); var userarealogout = $resource('/api/user_area/logout'); 

but doesn't feel quite right, i'm using methods, example:

this.login = function(credentials) {     var user = userarealogin.get(credentials, function() {         ...     }); };  this.signup = function(userinfo) {     var signup = userareasignup.get(userinfo, function() {         ...     }); }; 

i'm confused resources use, should have this?

var session = $resource('/api/user/session'); var userarea = $resource('/api/user');  userarea.get(credentials); //should login user? userarea.post(credentials); //should signup user? session.delete(); //should logout user? session.get(); //should sessions of logged user if any? 

by rest sessions maintained client , not service. should use https , send username , password every request (for example http basic auth headers) instead of using session cookies... (stateless constraint)

ofc. on client side can have login , logout change content of auth headers sent via ajax.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -