2017-07-26 5 views
0

私はアンゴラで新しいです。正面にログインユーザーを作成しようとしました。私の質問はユーザーのログインを保護する方法です。私はブラウザで店舗のユーザーのログイントークンのクッキーを実装し、それが正しい方法別のページを取得している?ログインとユーザーを角で固定する方法

this.loginService.login(this.user) 
     .subscribe(result => { 
      if (result != undefined){ 
       this.cookieService.putObject("logincookie", result); 
       this.router.navigate(['/userlist']); 
      } 

答えて

1

localStorageを使用するのが最も好ましい方法です。

this.loginService.login(this.user) 
    .subscribe(result => { 
     if (result != undefined){ 
      localStorage.setItem("username", result); 
      this.router.navigate(['/userlist']); 
     } 

あなたは、セキュリティの目的のためにのみusernamelocalStorageではなく、あなたのpassword保管しなければなりません。

AuthGuardを使用してログインせずにユーザーをナビゲートすることもできます。 AuthGuardの詳細な説明はhereです。

関連する問題