user-roles

PHP login class

岁酱吖の 提交于 2019-12-03 01:52:37
I'm looking for a good PHP login class via MySQL, and I'm not yet completely satisfied with anything I've found. This prior SO question doesn't really address my needs, as I'd prefer to stay away from PEAR and CodeIgniter, and just have a simple and small PHP class to do the job. There's a TalkPHP forum that has several to choose from, but they all seem to have something or other lacking. PHP Login Class by daz : seems a little tricky to extend, and doesn't support multiple user roles TalkPHP.com_Login_Script.PHP5.Beta_1 by Wildhoney : looks very extensible, supports configurable user roles,

ASP.NET Core Identity Add custom user roles on application startup

安稳与你 提交于 2019-12-03 01:31:53
In an ASP.NET Core application, I want to create certain roles as a basis to manage different user-permissions. Sadly, the documentation inform detailled how to use custom roles e.g. in controllers/actions, but not how to create them. I found out that I can use RoleManager<IdentityRole> for this, where the instance gets automatically injected in a controller-constructor, when its defined and ASP.NET Core identity is registered in the application. This let me add a custom role like this: var testRole = new IdentityRole("TestRole"); if(!roleManager.RoleExistsAsync(testRole.Name).Result) {

How to use Roles in user identity in MVC 5

二次信任 提交于 2019-12-03 00:16:09
I want to use asp.net useridentity in mvc 5, I do these steps: 1) create a mvc project. 2) create my own database and change the connectionstring in web.config form: to: 3) I run the project and create a new user to add related table to my database. 4) I wanted to add a role to a user after registration a user like this code in accountControler: public async Task<ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser() { UserName = model.Email, Email = model.Email }; IdentityResult result = await UserManager.CreateAsync(user, model.Password);

Custom my account new menu item for a specific user role in Woocommerce

戏子无情 提交于 2019-12-02 10:12:57
问题 I have created a few custom "My Account" endpoints for Woocommerce. I am trying to limit one to being visible per user role. For the following code, I would like it to only be visible for a user with the admin role. I have tried inserting a conditional if (current_user_can('administrator')) into my code, but haven't found a way that doesn't break the site. Any suggestions how to modify the following? /* Create Admin Tab on Woo Account Page -----------------------------------------------------

Apply a discount for a specific user role in Woocommerce

不想你离开。 提交于 2019-12-02 09:04:57
问题 I have a woocommerce store, with 3 user roles, I want to provide a 10% discount on the cart total only for a user role 'company'. I found "Percentage discount based on user role and payment method in Woocommerce" answer that is very neer of what I need, but don't know how to modify the code to feet my needs, as it contains also a condition based on payment method and displaying the discount only at checkout, but I need it to display in cart as well. 回答1: The following code will apply a 10%

Custom my account new menu item for a specific user role in Woocommerce

China☆狼群 提交于 2019-12-02 04:29:00
I have created a few custom "My Account" endpoints for Woocommerce. I am trying to limit one to being visible per user role. For the following code, I would like it to only be visible for a user with the admin role. I have tried inserting a conditional if (current_user_can('administrator')) into my code, but haven't found a way that doesn't break the site. Any suggestions how to modify the following? /* Create Admin Tab on Woo Account Page ------------------------------------------------------------------*/ function add_admin_tools_endpoint() { add_rewrite_endpoint( 'admin-tools', EP_ROOT | EP

Symfony2 FOSUserBundle Role entities

♀尐吖头ヾ 提交于 2019-11-30 19:06:45
I'm currently trying to figure out the best way to implement doctrine persisted Role entities as a M2M relationship compatible with FOSUserBundle. Previously I was using just strings with the default implementation and was persisting it with a doctrine array mapping. Now I need to have roles as seperate entites as we want to build an admin backend where others can grant users roles. Basically, it's a pain in the ass. The FOS interfaces are built for string representations, not Role entities. Change the implementation, you break a lot of stuff i.e. FOS commands to promote users. And it's hard

How to permit a SQL Server user to insert/update/delete data, but not alter schema?

旧巷老猫 提交于 2019-11-30 08:27:59
My application (C#, ASP.Net) needs to insert, update and delete data in the DB, and run stored procedures. I need to prevent it from modifying the DB schema - no altering tables, creating or dropping, no changes to stored procedures. What permissions combination do I need to grant to the application user? Just 'select' isn't going to work, because it needs to insert/update/delete data in tables. How do I check permissions and access for a particular login? How do I grant or deny permissions and access for a login? I need to give permissions to a new user (login) to access only one database.

ASP.NET MVC Check role inside view

人走茶凉 提交于 2019-11-30 05:52:27
In my View I have some admin links that I would like to hide and show based on user role how can do this inside the view e.g. <%= if(CHECK IF USER ROLE ADMIN) { %> <div class="tools"> <ul> <li class="edit"><%= Html.ActionLink("Edit", "Edit", new { id = Model.storyId }) %></li> <li class="delete"><%= Html.ActionLink("Delete", "Delete", new { id = Model.storyId }) %></li> </ul> </div> <%= } %> @if (this.User.IsInRole("Administrator")) { } <% if (Page.User.IsInRole("Admin")){ %> <%}%> However this is a terrible idea in my opinion. It is better to let the ViewData or Model represent what the view

Symfony2 FOSUserBundle Role entities

柔情痞子 提交于 2019-11-30 03:11:03
问题 I'm currently trying to figure out the best way to implement doctrine persisted Role entities as a M2M relationship compatible with FOSUserBundle. Previously I was using just strings with the default implementation and was persisting it with a doctrine array mapping. Now I need to have roles as seperate entites as we want to build an admin backend where others can grant users roles. Basically, it's a pain in the ass. The FOS interfaces are built for string representations, not Role entities.