With this code snippet, I am authenticating email and password using the customerlogin()
method. The method returns JSON data that I need to display on the next page. Essentially, I want to pass the data obtained from customerlogin()
to then()
and then forward it to /customerprofile
. Any assistance would be greatly appreciated.
logUserIn(form) {
this.submitted = true;
if (form.$valid) {
this.Auth.customerlogin({
email: this.operator.email,
password: this.operator.password
})
.then(() => {
// Successfully logged in, redirect to customer profile
this.$location.path('/customerprofile');
})
.catch(err => {
this.errors.login = err.message;
});
}
}
//Additional file Auth.js
customerlogin({
email,
password
}, callback) {
console.log('Customer Authentication Method');
return $http.post(properties.customer_login, {
email, password
})
.then(res => {
properties.GetId = res.data.id;
$cookies.put('token', res.data.token);
currentUser = User.get();
return currentUser.$promise;
})
.then(user => {
safeCb(callback)(null, user);
return user;
})
.catch(err => {
Auth.logout();
safeCb(callback)(err.data);
return $q.reject(err.data);
});
}
I need to display the data in these textboxes: take a look at the image here