0
Pour une raison quelconque, la partie connexion de mon application ne fonctionne pas sur Safari et Firefox.Angular 2 connexion ne fonctionne pas dans Safari et Firefox
Je reçois cette erreur en essayant d'authentifier.
Maintenant, le code fonctionne parfaitement en chrome.
Signin Service.ts
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Http, Headers, RequestOptions } from '@angular/http';
import { HttpWrapper } from '../../../shared/services/http-wrapper.service';
import { SERVER_URL } from '../../../shared/config/config';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
@Injectable()
export class SigninService {
constructor(
private http_native: Http,
private http: HttpWrapper
) { };
public login(user: { email: string, password: string }): Observable<any> {
let headers = new Headers({ 'Content-Type': 'application/json' });
headers.append('Accept', 'application/json;q=0.9,*/*;q=0.8')
let options = new RequestOptions({ headers: headers });
return this.http_native.post(`${SERVER_URL}users/login`, JSON.stringify(user), options)
.catch((error: any) => {
return Observable.throw(error);
})
.map((response: Response) => {
return response.json();
})
};
SinginComponent.ts
public login($event): void {
$event.preventDefault();
if (this.signinForm.valid) {
this.signinFormIsValid = true;
let { email, password } = this.signinForm.value;
this.signinService.login({ email, password })
.subscribe((response: any) => {
console.log('response', response);
sessionStorage.setItem('user', JSON.stringify(response));
this.loginDispatcherService.setUser(response);
this.availableParties = response.associatedPartyIds;
this.tokenId = response.authenticationTokenId;
this.stepOne = false;
this.stepTwo = true;
});
} else {
this.signinFormIsValid = false;
}
};
Toutes les suggestions sont les bienvenues.
J'ai es-shim installé. aussi je l'inclue comme ceci dans pollyfils.ts import 'core-js/client/shim'; –