I currently have a POST request which will in any case set location in the response header to go to the exact same page again.
1) I click sign in. As you can see, the location is set to /
which is the same page in this case. Request is handled by the server then a redirect via the location field is set in the response header.
2) Down below is the get request for the same address as the sign in page (not to be confused with /auth/local
which only receives a post with login credentials). /
is a different page when logged in due to routing in node.
3) As you can see below, the preview shows the html of the response to the get request which was initiated by the response of the post request. It's not the same as what the actual browser is showing which is the initial login page. It doesn't seem to update the browser?
Timeline:
I'm running Angular also:
main.js
angular.module('myApp', [])
.controller('publicHomeCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.submit = function (event) {
var data = {
email: $scope.email,
password: $scope.password
};
$http.post('/auth/local', data).success(function () {
console.log('success');
});
event.preventDefault();
};
$scope.submit2 = function () {
var data = {
email: $scope.email,
password: $scope.password
};
$http.post('/auth/local', data).success(function () {
console.log('success');
});
};
}]);
signin html
<div class="container" data-ng-controller="publicHomeCtrl">
<form method="post" role="form" ng-submit="submit($event)">
<input type="email" data-ng-model="email" placeholder="your@email.here" class="form-control">
<input type="password" data-ng-model="password" placeholder="password" class="form-control">
<button type="submit" class="btn btn-success">sign in 1</button>
</form>
<button ng-click="submit2()">sign in 2</button>
</div>
I'm suspecting because my http.post on the client side has a callback it cancels out the redirect in the response header from actually updating the view?