0

I am using Revel + angular for my application. The index page is the login interface, and once you are successful, you should be directed to the dashboard.html page. The problem is once I have made a POST request, I get a GET request with my 'response body', however, I am still in the login page. I am using angular to make a post request to my restful server. However, whenever I make a POST request I get status 302 on my POST request but my GET request fetches the response for the page.

My Angular Controller

appMainLogin.controller('MainLoginForm',function($scope, $http){

    $scope.user_email = null;
    $scope.user_pass = null;
    $scope.user_remember = true;

    $scope.userLogin = function () {

        var val = {
            "user_email": $scope.user_email,
            "user_pass": $scope.user_pass,
            "user_remember": $scope.user_remember,
            };
        var stringify = JSON.stringify(val);

    $http({
        url: '/login',
        method: 'POST',
        data: stringify || '',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
        }
    }).success($scope.getEmailData).error($scope.httpError);
            alert("error");
    };
});

My routes

POST /login App.Login
GET  /dash  Dash.Index

I get this: 302 on the POST request I get this: 200 OK on the GET request On the 'response body' of the GET request (firefox debugger) I see my I intended html page but I still remain in the index page.

Why is my app not redirecting to the dashboard.html(index.html->dashboard.html) after the user enters their login credential (based on my code above)?

RickyA
  • 15,465
  • 5
  • 71
  • 95
WarrenV
  • 230
  • 1
  • 2
  • 9
  • Can you explain again, more clearly, the order of HTTP requests you're making and the response you're getting? – New Dev Sep 23 '14 at 21:28
  • @NewDev- On the index page, you make a POST(url:/login) request to submit the login form (MainLoginForm angular controller). This request will call App.Login function (which will verify that the the user's credential is correct) then redirect to Dash.Index function (reverse routing) will render dash/index.html. This is very similar to the play framework. Please let me know if this does not make sense. – WarrenV Sep 24 '14 at 01:26
  • Can you list the sequence of calls and the server response to each? What call gets a 302? I don't fully understand from your question - it might clarify. I suggest you edit the original question rather than use the comments? – New Dev Sep 24 '14 at 01:32
  • @WarrenV did you figure out a solution? It sounds like Angular is not redirecting as expected. – Brenden Oct 30 '14 at 00:06

0 Answers0