Angularjs Yönlendirme URL'si sunucusuna Yetkilendirme başlığını geçmediğine

oy
0

Bir angularjs proje üzerinde çalışıyorum ve web'e oldukça yeni. Ne elde etmek çalışıyorum basit bir giriştir. Sunucu tarafındaki (nodejs) ve ayrıca müşteri tarafında, jeton temel kimlik uygulanan.

Her şey harika çalışıyor gibi görünüyor. i çalıştığınızda hariç

Bu. $ window.location.href

Benim kimlik doğrulama düzgün çalışıp çalışmadığını test etmek için, giriş tıkladığımızda, mükemmel çalışır yetkili bitiş noktasına bir $ http.get çağrıda bulundular. Sonra nodejs (hizmet) yapılan bir çağrı onay göstergesi başlığını ihtiyacı belirli bir son nokta, bana bir sayfa hizmet etmek istiyorum. Ama onun gönderiliyor değil.

  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);
        });

    }

nodejs kodu

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');
    }
};
Oluştur 12/03/2016 saat 16:26
kaynak kullanıcı
Diğer dillerde...                            


1 cevaplar

oy
-1

Böyle $ konumu kullanmalıdır:

 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");
        });

    }

Teşekkürler & Alkış

Cevap 12/03/2016 saat 17:53
kaynak kullanıcı

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