-
-
Save robwormald/1bf9d99be36ef24f788e 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.onLoginSuccess = function(loginResponse){ | |
TokenHandler.setToken(loginResponse.data.token); | |
return ({success:1, msg: "Logged in refreshing ....", type:"success"}) | |
}, | |
this.onLoginFailure = function(loginError){ | |
return ({success:0, msg: "LError Loggin in", type:"danger"}) | |
} | |
this.login = function(user_name, pass) { | |
var Auth = this; | |
return $http({ | |
url: 'http://127.0.0.1:8000/api-token-auth/', | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json' | |
}, | |
data: { | |
username: user_name, | |
password: pass, | |
} | |
}).then(Auth.onLoginResponse,Auth.onLoginError); | |
}, | |
this.logOut = function() {} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment