I've been trying to set up the satellizer's local signup and signin feature. The signup process is working, but I noticed that it first sends an OPTIONS request before sending a POST request.
The issue arises when I attempt to log in, as I receive a 400 error with the Network tab indicating the use of "OPTIONS". I have gone through several questions on this topic and most suggest adjusting the server-side permissions.
As a result, I have made the following additions to the server side to allow any type of request:
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "Authorization"
Despite these changes, I am still encountering the same error.
This is my login controller located within a modal:
angular.module('auth').controller('LoginCtrl',function($rootScope,
$scope, $location, $localStorage, $auth, $modalInstance,
$modal){
$scope.formData = {
email:'',
password:'',
};
$scope.master = {};
$scope.update = function(user) {
$scope.master = angular.copy(user);
};
$scope.reset = function(form) {
if (form) {
form.$setPristine();
form.$setUntouched();
}
$scope.user = angular.copy($scope.master);
};
$scope.reset();
$scope.ok = function () {
$modalInstance.close();
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
$scope.login = function(){
$auth.login({
email: $scope.formData.email,
password: $scope.formData.password,
grant_type: 'password'
}).then(function(res){
alert('success, WELCOME ' + res.data.user.email + '!')
}) .catch(function(err){
alert(err.message)
});
};
});
This is my app.js setup:
angular.module('app').config(function($stateProvider, $urlRouterProvider,
$authProvider,
$httpProvider, urls) {
/* Add New States Above */
$urlRouterProvider.otherwise('/home');
$authProvider.signupUrl = urls.BASE_API + '/Register';
$authProvider.loginUrl = urls.BASE + '/Token';
});
If anyone could provide assistance with this issue, it would be greatly appreciated.