Currently you need to manually create a token using the Token resource service and handle the HTTP response yourself. It would be better if we added a authentication service that would handle all of this.
The current flow looks like this:
var credentials = {
username: vm.credentials.username,
password: vm.credentials.password
};
var newToken = new Token(credentials);
newToken.$save().then(
function (token) { // success
// store token
sessionService.beginSession(token.Token);
// redirect back to the referrer or to the app root
var redirectState = $location.search().redirect_state; /* jshint ignore:line*/
if (redirectState) {
$state.go(redirectState);
} else {
$location.path('/');
}
},
function (error) { // error
if (error.status === 400) {
vm.invalidCredentials = true;
}
});
It should have a simple function signature like this:
authenticationService.authenticate(username, password)
.then(function(token) {
// redirect here
});
Currently you need to manually create a token using the Token resource service and handle the HTTP response yourself. It would be better if we added a authentication service that would handle all of this.
The current flow looks like this:
It should have a simple function signature like this: