Skip to content

Instantly share code, notes, and snippets.

Created August 7, 2014 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/a95a23564c6d9f07e48b to your computer and use it in GitHub Desktop.
Save anonymous/a95a23564c6d9f07e48b to your computer and use it in GitHub Desktop.
var myApp = angular.module('myApp');
myApp.service('Auth', function($http) {
this.login = function(user_name, pass) {
$http({
url: 'http://127.0.0.1:8000/api-token-auth/',
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
data: {
username: user_name,
password: pass,
}
}).success(function(data, status, headers, config) {
if (status == 200) {
TokenHandler.setToken(data.token);
return ({success:1, msg: "Logged in refreshing ....", type:"success"})
}
}).error(function(data, status, headers, config) {
return ({success:0, msg: "LError Loggin in", type:"danger"})
});
}
},
this.logOut = function() {
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment