Angular2: Login with api fails to get data sometimes

51 Views Asked by At

I'm trying to login on web with authentication of token got from Web-API. I am saving the token in cookies and proceed my work.

I want to ask that if i am login with admin on one tab and without logout, i will login again. Then, sometimes the result would not get as expected (data i got sometimes was incomplete).

Is this the issue of cookies ? Is it remembering the previous token that i have not cleared on previous tab login page. What should i do to fix this issue?

Please check the below code of login

Login(model: LoginViewModel): Observable<any> {
    // let body = "username=" + model.UserName + "&password=" + model.Password + "&grant_type=password" + "&client_id=" + "&client_secret=";
    let body = "username=" + model.UserName + "&password=" + model.Password + "&grant_type=password";

    let url = APIURL + "/token";

    return this._http.post(url, body, AuthService.OptionsUrlEncoded)
        .map(response => {
            this.AddClaims(response.json())
             this.ExpireTime();
        })

        .catch(this.HandleError);

}
0

There are 0 best solutions below