Search code examples
angularauthenticationsap-basis

Working with SAP login structure in Angular


My web app is Angular 7. I have a API endpoint for the user to login and sending requests to this URL and get the answers.

uri = 'https://mybackendurl.com/User';

  constructor(private http: HttpClient) { }

  signIn(email: string, password: string) {
    const httpOptions = {
      headers: new HttpHeaders({
        'Content-Type':  'text/xml',
        ...
      })
    };
    const soapData = '...';

    this.http.post(`${this.uri}`, soapData, httpOptions)

The structure I want to build is:

If the user has entered his / her information correctly, will be directed to a panel that uses this infrastructure. However, the user cannot login to the panel even if the user is logged in correctly. Because the URL wants some cookie information -it's called 'mysapsso2'. (I'm sorry, unfortunately my SAP knowledge is less) And bad news: I can't do it because the post method doesn't generate these unique cookies in Angular. (JS can't or I can't?)

I can't touch the backend URL. In this case, how can I get users to login to this panel using only the frontend skills?


Solution

  • The POST request is done with angular is stateless, so even you have done the login, the cookie is not passed to the backend server.

    I think the problem is due to cookie session absence. Try to add it manually with an Angular Interceptor.

    For more information read this answer.