Created
August 7, 2014 05:09
-
-
Save anonymous/a95a23564c6d9f07e48b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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