Services

Apart from the two services we have just mentioned, we have five more services:

  • AuthService:
    The path for this service is: clientappservicesauth.service.ts.
     This service defines four methods: 
     getCurrentUser login logout,  and  setCurrentUser.
  • UserService
    The path for this service is clientappservicesuser.service.ts.
    This service defines seven methods:  register, login, getUsers, countUsers, getUser, editUser, and deleteUser.
  • ThreadService
    The path for this service is clientappservices hread.service.ts.
    This service defines six methods:  getThreads, countThreads, addThread, getThread, editThread, and deleteThread.
  • MessageService
    The path for this service is clientappservicesmessage.service.ts.
    This service defines three methods: addMessage, editMessage, and deleteMessage.

These services are quite self-explanatory. Apart from these, there is another service named TokenInterceptor:  clientappserviceshttp.interceptor.ts. This service implements HttpInterceptor. In this service, we intercept every incoming and outgoing request. For every outgoing request, we add an authorization header assigning the value of JWT token that we have saved in local storage, if the token is present. And for every incoming request, we check the response status code. If the status code is 401 or 403, we kick the user out of the application and show message that they have performed an unauthorized activity.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.71.28