I'm learning to use token to authenticate users in angular.js front end.
I'm using below package(JSON Web Token Authentication support for Django REST Framework)
https://github.com/GetBlimp/django-rest-framework-jwt
I have implemented all settings and sample curl request is working fine.
Now I have login page with angularjs which posts to rest endpoint as shown in below code:
$http
.post('/api-token-auth/', {email: $scope.account.email, password: $scope.account.password})
.then(function(response) {
// assumes if ok, response is an object with some data, if not, a string with error
// customize according to your api
if ( !response.account ) {
$scope.authMsg = 'Incorrect credentials.';
}else{
$state.go('dashboard');
}
}, function(x) {
$scope.authMsg = 'Server Request Error';
});
Now when I post email and password then in the response I get successful token like this
{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InNhbXBsZUBzYW1wbGUuY29tIiwidXNlcl9pZCI6MSwiZW1haWwiOiJzYW1wbGVAc2FtcGxlLmNvbSIsImV4cCI6MTQyOTA5NjM5N30
.w0XV1kArTyZY9iCPyr2LmRzToD9iOgYlMVCoXmdOJ1A"}
Now as I don't know much about tokens, I want to know what should I do next? I mean after getting token how can I log the user in and put that user in some userObject in angular.