[Kendo for Angular] How to return the loged-in user ROLE_ ? - Forum - Mobile - Progress Community

[Kendo for Angular] How to return the loged-in user ROLE_ ?

 Forum

[Kendo for Angular] How to return the loged-in user ROLE_ ?

This question has suggested answer(s)

Hello,

I am using Kendo for Angular and OpenEdge 11.63

Currently I have 2 services:
1. ...MyApp/static/CrudService.json
2. ...MyApp/static/ReadOnlyService.json

I have 2 separate users:
1. admin with ROLE_PSCAdmin
2. user with ROLE_PSCUser

I separeted their login permissions and user (ROLE_PSCUser) can login only in ReadOnlyService.json and is working.

I don't know how to make the service in the front-end angular project. I am having JSDOSession which is working with one service. 

const _serviceURI = 'http://IP:8850/MyApp';
        const _catalogURI = _serviceURI + '/static/'+ 'Crud' + 'Service.json';
        const _catalogURI2 = _serviceURI + '/static/'+ 'OnlyRead' + 'Service.json';
        const authenticationModel = progress.data.Session.AUTH_TYPE_FORM;
        
        let opts: progress.data.JSDOSessionOptions = {
            serviceURI: _serviceURI,
            authenticationModel: authenticationModel  
        }

// create a new session object
        let _session = new progress.data.JSDOSession(opts);
        this.jsdoPromise = new Promise((resolve, reject) => {
            
            _session.login("username", "password").done(function (_session: progress.data.JSDOSession, result: any, info: any) {
                console.log("session.login");
                _session.addCatalog(_catalogURI).then(() => {
                    console.log("ADMIN");
                    resolve(self.jsdo = new progress.data.JSDO(self.tableName));
                });
            })
        })  



The first Idea I had was to get the ROLE_ from the server but I have no success. I tryed with this:

https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/asadm%2Finterpreting-the-appserverstatus-section.html%23

My second idea is to _session.login() and then to try one by one every _catalogURI and this way to get the user ROLE_, but I have no success as well.

Any suggestions?

Thanks,
Martin

All Replies
  • Hello Edsel,

    I am using JSDO 4.3.1 from npm (the last stable version), because 4.4.1 or 4.5 do not have typings and package.json in github. There is a 4.4.0 release for NPM, but it cant be installed trough the terminal.

    Martin

  • Hello Giorgi,

    > this function to angular 4? i have tried to use HttpClient and after debugging, it returns NULL or Undefined, does that

    > means x-client-props do not transport the role of the user?

    > if it does and I'm mistaken does user role reaches HTTP header after authentication? or before authentication?

    In the sample code above, the header is returned as part of the execution of an operation that reaches the AppServer. The InvokedHandler event is used.

    You would see the header when performing operations such as read, create, update, delete, submit and invoke. Operations such as login and addCatalog to access the AppServer.

    To have different users navigate over different components, I would suggest to have a Business Entity that manages this operation. After login, you would call an INVOKE operation to get the roles (or a mapping of the roles) for the user. Notice that with this approach, you would not need to use the x-client-props header.

    If you still need to use the approach of using headers, you can use the following code in Angular 4 to retrieve it:

    (This example shows the access using BASIC authentication.)

          let headers = new HttpHeaders();
          headers = headers.append('Authorization', 'Basic ' + btoa('<username>:<password>'));
    
          http.get('localhost:8810/.../Customer', {
              headers: headers,
              observe: 'response'
          }).subscribe((response) => {
            console.log('Response: ', response);
            console.log('Headers: ', response.headers);
            console.log('X-CLIENT-PROPS: ', response.headers.get('X-CLIENT-PROPS'));
          });

    I hope this helps.

  • Hello Martin,

    The jsdo NPM package that you are using was provided by community member Lars Neumeier.

    We are working on providing an NPM package with the latest JSDO version and up to date typings.

    This version would also remove the soft dependency on jQuery Promises.

    The NPM branch in GitHub corresponds to our current research / work. Once we have completed the work, the version would be available in the master branch.

    Product Management would be able to provide you with info on the roadmap.

    I hope this helps.

  • Thank you egarcia.

  • Hi Egarica,

    I am trying to build REST service using developer studio so that I can use it for one of my web based project.
    Below are screen shots:
    Inline image 1

    Inline image 2
    Inline image 4

    But when I am trying to use URL it is giving below error.
    Inline image 3

    OpenEdge explorer is running on port 9090.
    Inline image 5

    Please help me here.

  • Hi Arvind,
     
    From the screenshots I observed that, you are using port as 9090, this port is for OpenEdge explorer, not Rest manager. By default, rest manager will be running on port 8980. So, try with the following url:
     
    hope this helps,
    Sanjeev
     
  • Hi Sanjeev,

    Thanks for your help!

    After changing the port I I can hit think REST service but getting below error.

    Inline image 2
    RestService.log

    2017-11-29 14:56:59.414 [INFO][REST] --- --- REST Application Logging level set to =  2
    2017-11-29 14:56:59.415 [INFO][REST] --- --- REST Application Log entry types activated : REST
    2017-11-29 14:56:59.415 [INFO][REST] Adapter version : v11.3.0 (12-June-2013)
    2017-11-29 14:56:59.415 [WARN][REST] setting runTimeProperties location to ::C:\PROGRE~1.3\OpenEdge\servers\tomcat\webapps\restServiceService\WEB-INF\adapters\runtime.props
    2017-11-29 14:56:59.415 [INFO][REST] serviceAvailable = true
    2017-11-29 14:56:59.415 [INFO][REST] The application serviceAvailable value is true
    2017-11-29 14:56:59.415 [INFO][REST] Loaded runtime properties successfully from C:\PROGRE~1.3\OpenEdge\servers\tomcat\webapps\restServiceService\WEB-INF\adapters\runtime.props
    2017-11-29 14:56:59.415 [INFO][REST] InitialSetup successfully done.
    2017-11-29 14:56:59.416 [WARN][REST] Mbean Count:282
    2017-11-29 14:56:59.417 [INFO][REST] Registering Mbeans for Statistics and Status.
    2017-11-29 14:57:43.812 [INFO][REST] UnRegistering Mbeans for Statistics and Status.
    2017-11-29 14:57:43.813 [WARN][REST] Context Destroyed
    2017-11-29 14:57:49.584 [INFO][REST] --- --- REST Application Logging level set to =  2
    2017-11-29 14:57:49.584 [INFO][REST] --- --- REST Application Log entry types activated : REST
    2017-11-29 14:57:49.584 [INFO][REST] Adapter version : v11.3.0 (12-June-2013)
    2017-11-29 14:57:49.584 [WARN][REST] setting runTimeProperties location to ::C:\PROGRE~1.3\OpenEdge\servers\tomcat\webapps\restServiceService\WEB-INF\adapters\runtime.props
    2017-11-29 14:57:49.584 [INFO][REST] serviceAvailable = true
    2017-11-29 14:57:49.584 [INFO][REST] The application serviceAvailable value is true
    2017-11-29 14:57:49.585 [INFO][REST] Loaded runtime properties successfully from C:\PROGRE~1.3\OpenEdge\servers\tomcat\webapps\restServiceService\WEB-INF\adapters\runtime.props
    2017-11-29 14:57:49.585 [INFO][REST] InitialSetup successfully done.
    2017-11-29 14:57:49.585 [WARN][REST] Mbean Count:245
    2017-11-29 14:57:49.586 [INFO][REST] Registering Mbeans for Statistics and Status.
    2017-11-29 14:57:57.618 [INFO][REST] An HTTP Request received in Enabled State. Sending Request to the Adapter Servlet.
    2017-11-29 14:57:58.012 [INFO][REST] OpenEdge Procedure name: Customer
    2017-11-29 14:57:58.012 [INFO][REST] OpenEdge Internal Procedure name: ReadCustomer
    2017-11-29 14:57:58.100 [INFO][REST] AppServer Endpoint connected: null
    2017-11-29 14:57:58.100 [INFO][REST] Executing a SingleRun class
    2017-11-29 14:57:58.100 [INFO][REST] Creating singleton class Customer
    2017-11-29 14:57:58.103 [INFO][REST] Internal procedure name is ReadCustomer
    2017-11-29 14:57:58.104 [INFO][REST] Running an internal procedure: Customer->ReadCustomer
    2017-11-29 14:57:58.125 [ERROR][REST] ABL Runtime error
    2017-11-29 14:57:58.126 [ERROR][REST] Exception in AppServerProducer :: ABL Runtime error
    2017-11-29 14:57:58,136 5    [http-bio-8980-exec-203] ERROR org.apache.camel.processor.DefaultErrorHandler error  - Failed delivery for (MessageId: ID-HBADT4300592-57867-1511947668754-0-1 on ExchangeId: ID-HBADT4300592-57867-1511947668754-0-2). Exhausted after delivery attempt: 1 caught: com.progress.open4gl.Open4GLException: ABL Runtime error
    com.progress.open4gl.Open4GLException: ABL Runtime error


  • Hi Arvind,

    Please check the appserver log file. There is an error instantiating your class.

    Kind regards,

    Daniel.

  • Hi Arvind,
     
    From screenshot in previous post, I can see that Business Logic is not published to rest broker (restbroker1). If this is true, follow the below steps:
    1. Create restbroker1 in server view (Right click in servers view and then select New > Server, click Next and then select restbroker1 from broker combo and then click Finish.
    2. Double click on restbroker1 from servers view and then click “Launch configuration” from server editor
    3. Go to Databases tab and then add database connection and click OK in Server Launch configuration
    4. Now right click on restbroker1 from servers view and then select “Add and Remove…” menu option
    5. Add the current project module to restbroker1 and click OK.
    6. Now start restbroker1, this will publish the business logic (Business Entities in your case)
    7. Now try to access the service URL, you can see the results in browser
     
    Hope this helps,
    Sanjeev
  • Thanks allot Sanjeev!

    it is working now.

    So here we need OpenEdge AppServer --> restbroker not OE Web Server?

  • Hi Arvind,
     
    In case of Classic servers, Services need to be published to OE Web Server (restmgr1) and Business Logic needs to be published to OpenEdge AppServer (restbroker1).
     
    If you have Progress Application Server for OpenEdge (PAS OE), then both services and business logic can be published to only one server. PAS OE is supported from OpenEdge 11.5.x onwards.
     
    Hope this helps,
    Sanjeev
     
  • I got your point .

    I don't have PAS server , but if it is there then it will look like this?
    Inline image 1

  • Yes, that’s true.
     
    Thanks,
    Sanjeev
     
  • Hi Sanjeev,

    When I am trying to edit REST service I am getting this window instead of the one for mapping input & output  parameters?

    Inline image 1

    Also is there any document or video or anything that will explain more about how to get input parameters to back-end then return back some output value to web?