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
Solved! Go to Solution.
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?
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()
);
}
}
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
It should return value for logged in user. Are you sure you are logged in at the time of ngOnInit call or your HomeComponent?
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
What versions of the JS-API and ADF components you are using?
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"
},
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?
That worked, thanks a lot
Discussions, help and advice about the Alfresco Development Framework.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.