06-21-2017 03:40 PM
Hello everyone,
Im working on an ADF app which connects to my ECM repository, the purpose of the app is to have a more responsive alternative to consumers so the can view and download documents even on their cellphones, for this i have created a custom page component for each site on my repository, and on the home page i want to display the links for the sites which the current user has access to, but for this i use this api AlfrescoApiService..getInstance().core.sitesApi.getSiteMember(sitename, userId ) and i need to somehow obtain the id of the user that has accessed the app,
Any help would be appreciated,
Thanks a lot
06-22-2017 10:15 AM
The "alfresco-js-api" version is outdated. I believe storing logged in usernames for process/content services was added in 1.5.0. Could you please update it to "1.5.0" and run "npm install" once again?
06-21-2017 04:22 PM
You can try using "AlfrescoAuthenticationService" if you want to get access to current username. The service exposes a method "getEcmUsername".
export class MyComponent {
constructor(private authService: AlfrescoAuthenticationService) {}
myMethod() {
console.log(
this.authService.getEcmUsername()
);
}
}
06-22-2017 09:42 AM
Hi, thanks for the reply,
like you suggested i tried using AlfrescoAuthenticationService but it doesnt seem to recongise the current user logged in, here is what my code is like:
but i am getting undefined as a result, do you know why could have happened?
thanks
06-22-2017 09:46 AM
It should return value for logged in user. Are you sure you are logged in at the time of ngOnInit call or your HomeComponent?
06-22-2017 09:54 AM
When i inspect the page it gives me this result
the login was succesful and the true value was the result of "console.log(this.authService.isLoggedIn());"
the undefined value is the result of asking the current logged user
06-22-2017 10:02 AM
What versions of the JS-API and ADF components you are using?
06-22-2017 10:12 AM
I´m using the community edition version 5.2, also checking the versions.json of my adf app i get this:
"alfresco-js-api": {
"version": "1.4.0",
"from": "alfresco-js-api@~1.4.0",
"resolved": "https://registry.npmjs.org/alfresco-js-api/-/alfresco-js-api-1.4.0.tgz"
},
"ng2-alfresco-core": {
"version": "1.5.0",
"from": "ng2-alfresco-core@1.5.0",
"resolved": "https://registry.npmjs.org/ng2-alfresco-core/-/ng2-alfresco-core-1.5.0.tgz"
},
"ng2-alfresco-login": {
"version": "1.5.0",
"from": "ng2-alfresco-login@1.5.0",
"resolved": "https://registry.npmjs.org/ng2-alfresco-login/-/ng2-alfresco-login-1.5.0.tgz"
},
06-22-2017 10:15 AM
The "alfresco-js-api" version is outdated. I believe storing logged in usernames for process/content services was added in 1.5.0. Could you please update it to "1.5.0" and run "npm install" once again?
06-22-2017 10:48 AM
That worked, thanks a lot
Explore our Alfresco products with the links below. Use labels to filter content by product module.