Angular – Display Dashboard and other component.html based on user_id

Am unable to display component.html and dashboard based on user_id

I am using Angular to connect to Laravel endpoints. I have User model and other models. Every other tables have user_id in it. There are two dashboards: admin-dashboard and user-dashboard.

Laravel

    public function login()
    {
        $credentials = request(['email', 'password']);

        if (!$token = auth()->attempt($credentials)) {
            return response()->json(['error' => 'Email or Password doesn't exisit'], 401);
        }

        return $this->respondWithToken($token);
    } 

models for user, student and assignment:


    protected $fillable = [
        'name', 'email', 'password', 'username',
    ];

    protected $fillable = [
        'name', 'class', 'user_id',
    ];
    protected $fillable = [
        'title', 'valid_date', 'content', 'user_id',
    ];

Angular: Service

  private baseUrl = 'http://localhost/cloudengine-sandbox/cloudsandboxbackend/public/api';
  //private baseUrl = '/api';


  constructor(private http:HttpClient) { }

  register(data){
    return this.http.post(`${this.baseUrl}/register`, data)
  }
  login(data){
    return this.http.post(`${this.baseUrl}/login`, data)
  }

login.component.ts

  onSubmit() {
  this.Jarwis.login(this.form).subscribe(
     data => this.handleResponse(data),
     error => this.handleError(error)
  );
  }

  handleResponse(data){
 this.Token.handle(data.access_token);
 this.Auth.changeAuthStatus(true);
 //this.user.loggedInUser = user;
 this.router.navigateByUrl('/admindashboard');
  }

When I login:

  1. If user_id is 1, it should redirect to admindashboard else userdashboard
  2. The admin should see everything in the application, while other users should see the components/forms that its table has the user_id of that particular user

Source: AngularJS