domfarolino / angular2-login-seed

(deprecated) Seed app w/ Angular2, Node, Express, and OAuth login
https://domfarolino.com/angular2-login-seed
MIT License
181 stars 77 forks source link

After login, where do you store the session token? #10

Closed caalvinz closed 7 years ago

caalvinz commented 7 years ago

Here is the login method. I can't find how and where the token is stored and how to send it to server. Could you give me some idea about this? Thanks.

login(user) {
    let body = JSON.stringify(user);
    let headers = new Headers();
    headers.append('Content-Type', 'application/json');

    return this.http.post(this._loginApi, body, <RequestOptionsArgs> {headers: headers, withCredentials: true})
                    .map((res: Response) => res)
                    .catch(this.handleError);
  }
domfarolino commented 7 years ago

The express server sends a Set Cookie header in the login response, the client is allowed to set the cookie as a result of the withCredentials: true option in the <RequestOptionsArgs>. Does this clear it up at all? I admit it is a little odd looking with out explicit client side storage logic

caalvinz commented 7 years ago

Got it, thanks a lot.

domfarolino commented 7 years ago

@Ewebalvin feel free to email me with any questions: domfarolino@gmail.com