I'm trying to dynamically display a button in the detail view of a given record, depending on its record and the role of the current user. In order to do so, I'm including a custom javascript file in a detail view definition file, in custom/modules/Tasks/metadata/hide.js.
I need to access to the roles of a user, so first I'm trying to access to the user object. However, this fails:
var user = app.data.createBean('Users', {id: app.user.id});
It throws the following error: ReferenceError: app is not defined.
What's the right way to get the user (and then the role) through javascript in SugarCRM Enterprise 6.5?
The code you are using will work only with sugarcrm 7 or later versions.
App variable is not available in sugar 6.5.
You need to write custom api to get user roles.
In php you can get roles like this
global $current_user;
include_once('modules/ACLRoles/ACLRole.php');
$roles = getUserRoleNames($current_user->id);
print_r($roles);
Related
When using XPages in Lotus Domino Designer, I encounter the following error (displayed in log file) on trying to set the view formula dynamically.
com.ibm.xsp.exception.EvaluationExceptionEx: Error while executing JavaScript computed expression
The following code fails ...
var helpview:NotesView = db.getView(viewNm);
var strQS:string= sessionScope.searchKey;
helpview.setSelectionFormula(strQS);
Error takes place at the setSelectionFormula line. strQS is the string for view selection formula.
This message just means there's an error in your code. Error handling will identify more details of why. Something like XPages OpenLog Logger (which is also incorporated into OpenNTF Domino API, if you also want that) will identify the cause. XPages OpenLog Logger captures the cause regardless of whether or not there is specific error handling on that block, providing a custom error page is added to the application.
The most probable cause, though, is that the user the database is being retrieved under does not have at least Designer access to the database, either in the ACL or Maximum Internet Access on the Advanced tab of the ACL.
I am coding a webapp using JHipster code generator.
I created 2 extra roles, now I have 5 in total:
ROLE_USER, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_PRESIDENT, ROLE_VICE_PRESIDENT
I was wondering how could I manage their permissions to show some RESTs.
For example, I would like to let the PRESIDENT add new users to database, other simple users should not see the web service that do the work.
Is there a file that I'm ignoring by mistake that could help me with this feature?
Giving thanks in advice for your precious time,
Manuel
Adding new roles to JHipster needs to be added in 2 places.
The obvious one is the AngularJS frontend. To add your new role to user edit view, you add them to the select options in "user-management.controller.js" at vm.authorities = ['ROLE_USER', 'ROLE_ADMIN']
To enforce the role at different places in UI, you either add your roles to the state JS files. Just add them to data.authorities (check user-management.state.js)
If you like to have a template block visible only if a user has the proper role, check out the hasAnyAuthority directive.
The other Part is to secure the backend. If using a current JHipster version and SQL database, authorities are stored in the database. Add your custom roles to authorities.csv of your liquibase migrations.
Last but not least, you can enforce roles in WebSecurityConfiguration or MicroserviceSecurityConfiguration (just look at the existing antMatchers)
I'm trying to write a plugin for TFS 2015 (its important). I read a couple of manuals. the examples all turns out simply, but it is more difficult with a real plugin. my problem:
-How do I get all the teams that the user member is
i can get current team from web context:
var context = VSS.getWebContext();
var currTeam = context.team;
but how can i get all avaible teams and groups for current user(or by id)?
To get teams for current user
You could get the teams through this method getTeams() directly
IPromise<Contracts.WebApiTeam[]> getTeams(projectId, top, skip)
To get groups for current user
It's not able to do this through js or rest api for now. You could either use tfs command to list the info or use TFS API to achieve what you want. Related method in API: List application groups(), readidentities()
Detail code please refer this question: How to get TFS user groups and users in particular group using TFS API?
Another script solution you could also take a look, just in case you are interested: Using PowerShell and TFS API to list users
Using Identity 2.0 with a Web Forms project.
I can login successfully, and control access to pages using <allow users="<emailaddress>"/>, but when I add a user to a role in AspNetUserRoles, it causes the application to return this error:
The specified cast from a materialized 'system.int32' type to the 'system.string' type is not valid
The string of code that Visual Studio references on the crash is:
var user = manager.FindByName(Email.Text)
How can I fix this?
Discovered the problem. Our DB editor had changed the AspNetRoles table so that the RoleID field would auto-increment, and in doing so, the field changed from an NVARCHAR(256) to an INT. Changed it back and the problems has been resolved.
Is there any object or code (javascript, php...) that can be integrated to check if an application name is available in the app store?
If you want to check if a name is available for your app on Apple AppStore, you have to use itunesconnect website, and try to create a new application, it will ask you for the name, if it is not available you will not be able to proceed with the creation of it.
If you want to take the name, finish the creation of the application on itunesconnect, you can always edit it before to submit for the final review.