Skip to content

Commit faf2752

Browse files
damienmoulardClement-Roque
authored andcommitted
add roles management for api accessibility
1 parent 9d4e322 commit faf2752

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Diff for: Zenergy/Zenergy/Controllers/ApiControllers/usersController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ public usersController()
2626
}
2727

2828
// GET: api/users
29+
2930
[Authorize(Roles = "Admin")]
3031
public IQueryable<user> Getuser()
3132
{
3233
return db.user;
3334
}
3435

3536
// GET: api/users/5
36-
//[Authorize(Roles = "Admin")]
3737
[ResponseType(typeof(user))]
3838
public async Task<IHttpActionResult> Getuser(int id)
3939
{

Diff for: Zenergy/Zenergy/Providers/ApplicationOAuthProvider.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwner
5151
identity.AddClaim(new Claim("mail", context.UserName));
5252
identity.AddClaim(new Claim("role", "user"));
5353
identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName));
54+
5455
//identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.userId.ToString()));
5556
identity.AddClaim(new Claim("UserId", user.userId.ToString()));
5657

57-
/*
5858
if (user.member != null)
5959
{
6060
identity.AddClaim(new Claim(ClaimTypes.Role, "Member"));
@@ -70,7 +70,7 @@ public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwner
7070
if (user.admin != null)
7171
{
7272
identity.AddClaim(new Claim(ClaimTypes.Role, "Admin"));
73-
} */
73+
}
7474

7575
if (user.member != null)
7676
{

0 commit comments

Comments
 (0)