Hi All,
I’m new to Ionic and i wanted to check about securing the authentication data. I have this method to login to the web service, and everytime i wanted to access the web service, i’d need to put my email and password in the header. Is there any way to securely store this information? Thanks.
login(email, password): Promise {
let user: User;
this.authString = 'Basic ’ + btoa(email + ‘:’ + password);
…
}
getEntriesData(): Promise<Entry[]> {
console.log("User data: " + this.user);
if (this.user && this.authString && this.authString!=’’) {
return this.http.get(this.getEntriesUrl, {headers: this.getHeaders()})
.toPromise()
.then(response => response.json() as Entry[])
.catch(this.handleError);
}
else {
return null;
}
}
private getHeaders(){
let headers = new Headers();
headers.append(‘Accept’, ‘application/json’);
headers.append(‘Authorization’, this.authString);
return headers;
}