title: Angular subscribe to login service and get special field from logged in user
body: <p>I've got boolean field in user model and I need to open a modal window on the login page right after the user pressed <em>submit</em> and got info from server after I checked user.user_on_test field and open modal only if it's true. Can you please help me to extract this info from response?</p>
  
  <p>This is my user.service</p>
  
  <pre class="lang-js prettyprint-override"><code>    @Injectable()
      export class UserService extends BaseService {
        protected API_PATH: string;
  
        constructor( protected _http: HttpClient ) {
         super( _http );
         this.API_PATH += '/rest-auth';
         this.getUserData().subscribe();
        }
  
        private _user: BehaviorSubject&lt;User&gt; = new BehaviorSubject( null );
  
        get user(): Observable&lt;User&gt; {
          return this._user.asObservable();
        }
  
        set user( user ) {
         if ( &lt;User&gt;user ) {
          this._user.next( new User( user ) );
          localStorage.setItem( 'active', ( &lt;User&gt;user)
            .is_active.toString() );
          localStorage.setItem( 'superuser', ( &lt;User&gt;user)
            .is_superuser.toString() );
          localStorage.setItem( 'user_on_test', ( &lt;User&gt;user)
            .user_on_test.toString() );
          } else {
          this._user.next( null );
            localStorage.removeItem( 'active' );
            localStorage.removeItem( 'superuser' );
            localStorage.removeItem( 'user_on_test');
           }
         }
  
       public login( user: User ): Observable&lt;any&gt; {
        return Observable.concat(
         this.request( {
          'method': 'POST',
          'url': '/login/',
          'body': {
            username: user.username,
            password: user.password
          }
         } ),
         this.getUserData()
        );
       }
  </code></pre>
  
  <p>and login.component:</p>
  
  <pre class="lang-js prettyprint-override"><code>    login() {
        this.errorMsg = '';
        this._authService.login( this.user )
          .takeUntil( this.destroy$).subscribe(
          (response) =&gt; {
          if (this._authService.user) {
          // here I need to check user.user_on_test
            alert('this user is on test server!');
          }
          if ( this.redirect ) {
            const url = this._route.snapshot.queryParams['returnUrl'] ||'/';
            this._router.navigate( [ url ] );
          }
        },
        ( rejection ) =&gt; {
          if ( rejection &amp;&amp; rejection.hasOwnProperty( 'error' ) &amp;&amp; 
         rejection.error.non_field_errors ) {
            for (const error in rejection.error.non_field_errors) {
              if (rejection.error.non_field_errors.hasOwnProperty(error)) {
                this.errorMsg = rejection.error.non_field_errors[error];
              }
            }
          }
        });
        }
  </code></pre>