Angularjs Przekierowanie URL nie przechodząc nagłówek Authorization do serwera

głosy
0

Pracuję nad projektem angularjs i jestem całkiem nowy w internecie. Co staram się osiągnąć jest prosty logowania. I wprowadziły tokenu uwierzytelniania bazowej, po stronie serwera (nodejs), a także po stronie klienta.

Wszystko wydaje się działać świetnie. Z wyjątkiem gdy próbuję

tego. $ window.location.href

Kiedy klikam logowanie, aby sprawdzić, czy mój uwierzytelnianie działa prawidłowo, mam nazwać $ http.get do autoryzowanego punktu końcowego to działa idealnie. Potem zrobić wezwanie do nodejs (służyć), aby służyć mi stronę w danym punkcie końcowym, który wymaga autoryzacji tokenu nagłówka. Ale to nie są wysyłane.

  public loginClick = () => {
        this.authService.login(this.user).then(msg => {
            console.log(success);
            this.$http.get(Config.apiEndpoint().url + '/memberinfo').then(result => { 

                console.log(result.data); //<== this works
                var landingUrl = http:// + this.$window.location.host + /dashboard/;
                this.$window.location.href = landingUrl; //<== this does not works
            });

        }, errMsg => {
            console.log(failes);
        });

    }

Kod nodejs

app.get('/', moduleRoutes.root);
app.get('/dashboard/', moduleRoutes.root);

export function root(req: express.Request, res: express.Response) {
    if (authorization.isAuthorized(req, res)) {
        res.sendfile('./public/views/index.html');
    } else {
        res.sendfile('./public/views/login.html');
    }
};
Utwórz 12/03/2016 o 16:26
źródło użytkownik
W innych językach...                            


1 odpowiedzi

głosy
-1

należy użyć $ lokalizację tak:

 public loginClick = () => {
        this.authService.login(this.user).then(msg => {
            console.log("success");
            this.$http.get(Config.apiEndpoint().url + '/memberinfo').then(result => { 

                console.log(result.data);
                $location.path('/dashboard');
            });

        }, errMsg => {
            console.log("failes");
        });

    }

Dzięki i Pozdrawiam

Odpowiedział 12/03/2016 o 17:53
źródło użytkownik

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more