user-roles

ASP.NET MVC Check role inside view

£可爱£侵袭症+ 提交于 2019-12-18 12:13:21
问题 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> <%= } %> 回答1: @if (this.User.IsInRole("Administrator")) { } 回答2: <% if (Page.User.IsInRole("Admin")){ %> <%}%>

Managing users/roles/groups in FOSUserBundle

独自空忆成欢 提交于 2019-12-18 11:17:39
问题 I am developing a simple CRUD to manage users/roles/groups of the application in which I am working. To manage users I'm using FOSUserBundle . What I want to do can be accomplished in several ways: Assigning roles to groups and then assign users to these groups Assigning roles to users directly But I have no idea how. I knew that FOSUser BaseUser class already has a column roles and in the documentation of FOSUser explains how to establish a ManyToMany relationship between users and groups

How to use a MVC WebAPI OData endpoint securely?

≡放荡痞女 提交于 2019-12-18 09:23:25
问题 I have an OData endpoint defined at ~/odata/ , which doesn't need to be accessed unless a user has been authenticated (in fact, how would you secure this for non-authenticated users). I setup role-based authentication to this path in the web.config with: <location path="odata"> <system.web> <authorization> <allow roles="WaitConfirmation, etc...."/> </authorization> </system.web> </location> When a user logs in, I don't use the OData endpoint for authentication (primarily because I need to

CouchDB-wide read-only access rights

余生长醉 提交于 2019-12-17 23:04:30
问题 I need to create a CouchDB user which can only read documents from any database but can't write any of them. As far as I'm concerned, it is not what is supported by default (user types are described here). As the wiki says, access rights are given per database, so it seems what I am trying to do is not the best way to use CouchDB. Anyway, it would be great to do that. Could you please give me some tips on how to implement that? 回答1: You will need to put a design doc in each database you want

.net MVC add roles and add users and add roles to users + make part of a view only visible for a role [closed]

不想你离开。 提交于 2019-12-13 06:50:10
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 years ago . I am new to .net and have to create a project for school. I am using an MVC 5 template and it has a standard login but now I need 2 roles: student and teacher. How and where do I create those roles? And then how do I make it so that only logged in people can the last item from this nav <div class=

MVC Simple Membership Web Site Administration Tool

ぐ巨炮叔叔 提交于 2019-12-13 00:56:48
问题 I must have missed this somewhere (or slept through the class)... the standard ASP security tool for managing users and roles seems to be absent when using the new simple security version. That is, the original is there and working, just points to traditional ASP security... NOT to the new "simple" system. In my project I can log in, I can look at the webpages_ tables but can find no method of accessing them in my project... I would be happy to manage roles and get the USERID and maybe ROLEID

How to add roles to the asp identity bearer token

隐身守侯 提交于 2019-12-12 10:15:02
问题 I implemented OWIN bearer token authorization, and based on this article: http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/, and now i want to add roles to the bearer token so that i can be able retrieve it on the controller like am doing with the userName... identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName)); and was able to get the username of the current user with User.Identity.Name 回答1: Check my latest post on bitoftechwhere I

set role for users in edit form of sonata admin

微笑、不失礼 提交于 2019-12-12 09:46:25
问题 I'm using Symfony 2.1 for a project. I use the FOSUserBundle for managing users & SonataAdminBundle for administration usage. I have some questions about that: As an admin, I want to set roles from users in users edit form. How can I have access to roles in role_hierarchy ? And how can I use them as choice fields so the admin can set roles to users? When I show roles in a list, it is shown as string like this: [0 => ROLE_SUPER_ADMIN] [1 => ROLE_USER] How can I change it to this? ROLE_SUPER

Rails Cancan: Defining Default Role on Signup

僤鯓⒐⒋嵵緔 提交于 2019-12-12 05:39:12
问题 I've recently added roles to my rails application with CanCanCan (by enumeration)- but now I want to add a default role on signup. How do I go about doing this? Does it go in the controller or model? My User model: class User < ActiveRecord::Base #Defining different roles enum role: [:Admin, :User, :Guest] #Users can only create one scholarship application has_one :applications # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable

Fix Wordpress broken database : capabilities / no role assigned

隐身守侯 提交于 2019-12-11 17:59:44
问题 I'm working on a Wordpress website having this bug : 9000 users should be "subscriber" (Wordpress role), but they have no role assigned now (probably due to a users import script) : Image : http://i.imgur.com/GulqggZ.jpg In the meta_value, we can see their name instead of the role : Dupont, Maurice ... How can I assign the role/capability "subscriber" to all users without role ? I found a plugin doing this in bulk but it cannot handle more than 1000-2000 users and the link for download is