Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
ProjectsStatusManagement
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hasan.bahjat
ProjectsStatusManagement
Commits
fb047242
Commit
fb047242
authored
Aug 31, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix roles / gather the role in a one place
parent
48a31497
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
4 deletions
+49
-4
RolesNames.cs
PSManagement.Domain/Identity/Constants/RolesNames.cs
+25
-0
SeedData.cs
...nt.Infrastructure.Persistence/SeedDataContext/SeedData.cs
+7
-4
CustomersController.cs
...Presentation/Controllers/Customers/CustomersController.cs
+10
-0
ProjectsController.cs
...t.Presentation/Controllers/Projects/ProjectsController.cs
+3
-0
RolesController.cs
...agement.Presentation/Controllers/Roles/RolesController.cs
+2
-0
UserRolesController.cs
...ent.Presentation/Controllers/Roles/UserRolesController.cs
+2
-0
No files found.
PSManagement.Domain/Identity/Constants/RolesNames.cs
0 → 100644
View file @
fb047242
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
PSManagement.Domain.Identity.Constants
{
/// <summary>
/// Provide a role nmaes
/// </summary>
/// this classs provide a contant role names
/// gathering the roles source in a one place make change roles easier
///
public
static
class
RolesNames
{
public
const
string
ADMIN
=
"Admin"
;
public
const
string
PROJECTS_PLANNER
=
"Projects-Planner"
;
public
const
string
CUSTOMERS_PLANNER
=
"Customer-Planner"
;
public
const
string
EMPLOYEE
=
"Employee"
;
public
const
string
SCIENTIFIC_DEPUTY
=
"Scientific-Deputy"
;
}
}
PSManagement.Infrastructure.Persistence/SeedDataContext/SeedData.cs
View file @
fb047242
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Logging
;
using
PSManagement.Domain.Employees.Entities
;
using
PSManagement.Domain.Employees.Entities
;
using
PSManagement.Domain.Identity.Constants
;
using
PSManagement.Domain.Identity.Entities
;
using
PSManagement.Domain.Identity.Entities
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
...
@@ -42,10 +43,12 @@ namespace PSManagement.Infrastructure.Persistence.SeedDataContext
...
@@ -42,10 +43,12 @@ namespace PSManagement.Infrastructure.Persistence.SeedDataContext
{
{
builder
.
Entity
<
Role
>().
HasData
(
builder
.
Entity
<
Role
>().
HasData
(
new
Role
{
Id
=
1
,
Name
=
"Admin"
},
new
Role
{
Id
=
1
,
Name
=
RolesNames
.
ADMIN
},
new
Role
{
Id
=
2
,
Name
=
"Employee"
},
new
Role
{
Id
=
2
,
Name
=
RolesNames
.
EMPLOYEE
},
new
Role
{
Id
=
4
,
Name
=
"Scientific-Deputy"
},
new
Role
{
Id
=
4
,
Name
=
RolesNames
.
PROJECTS_PLANNER
},
new
Role
{
Id
=
5
,
Name
=
"Planner"
}
new
Role
{
Id
=
5
,
Name
=
RolesNames
.
SCIENTIFIC_DEPUTY
},
new
Role
{
Id
=
6
,
Name
=
RolesNames
.
CUSTOMERS_PLANNER
}
);
);
...
...
PSManagement.Presentation/Controllers/Customers/CustomersController.cs
View file @
fb047242
...
@@ -19,10 +19,12 @@ using PSManagement.Application.Customers.UseCases.Queries.GetCustomer;
...
@@ -19,10 +19,12 @@ using PSManagement.Application.Customers.UseCases.Queries.GetCustomer;
using
Ardalis.Result
;
using
Ardalis.Result
;
using
PSManagement.Application.Customers.UseCases.Commands.RemoveContactInfo
;
using
PSManagement.Application.Customers.UseCases.Commands.RemoveContactInfo
;
using
PSManagement.Presentation.Controllers.ApiBase
;
using
PSManagement.Presentation.Controllers.ApiBase
;
using
PSManagement.Domain.Identity.Constants
;
namespace
PSManagement.Presentation.Controllers.Customers
namespace
PSManagement.Presentation.Controllers.Customers
{
{
[
Route
(
"api/[controller]"
)]
[
Route
(
"api/[controller]"
)]
[
Authorize
]
[
Authorize
]
public
class
CustomersController
:
APIController
public
class
CustomersController
:
APIController
{
{
...
@@ -55,7 +57,10 @@ namespace PSManagement.Presentation.Controllers.Customers
...
@@ -55,7 +57,10 @@ namespace PSManagement.Presentation.Controllers.Customers
return
HandleResult
(
_mapper
.
Map
<
Result
<
CustomerResponse
>>(
result
));
return
HandleResult
(
_mapper
.
Map
<
Result
<
CustomerResponse
>>(
result
));
}
}
[
HttpPost
]
[
HttpPost
]
[
Authorize
(
Roles
=
RolesNames
.
CUSTOMERS_PLANNER
)]
public
async
Task
<
IActionResult
>
Post
(
CreateCustomerRequest
request
)
public
async
Task
<
IActionResult
>
Post
(
CreateCustomerRequest
request
)
{
{
var
command
=
_mapper
.
Map
<
CreateCustomerCommand
>(
request
);
var
command
=
_mapper
.
Map
<
CreateCustomerCommand
>(
request
);
...
@@ -81,6 +86,7 @@ namespace PSManagement.Presentation.Controllers.Customers
...
@@ -81,6 +86,7 @@ namespace PSManagement.Presentation.Controllers.Customers
}
}
[
Authorize
(
Roles
=
RolesNames
.
CUSTOMERS_PLANNER
)]
[
HttpDelete
(
"{id}"
)]
[
HttpDelete
(
"{id}"
)]
public
async
Task
<
IActionResult
>
Delete
(
int
id
)
public
async
Task
<
IActionResult
>
Delete
(
int
id
)
{
{
...
@@ -92,6 +98,7 @@ namespace PSManagement.Presentation.Controllers.Customers
...
@@ -92,6 +98,7 @@ namespace PSManagement.Presentation.Controllers.Customers
}
}
[
Authorize
(
Roles
=
RolesNames
.
CUSTOMERS_PLANNER
)]
[
HttpPut
(
"{id}"
)]
[
HttpPut
(
"{id}"
)]
public
async
Task
<
IActionResult
>
Put
(
int
id
,
UpdateCustomerRequest
request
)
public
async
Task
<
IActionResult
>
Put
(
int
id
,
UpdateCustomerRequest
request
)
{
{
...
@@ -108,7 +115,9 @@ namespace PSManagement.Presentation.Controllers.Customers
...
@@ -108,7 +115,9 @@ namespace PSManagement.Presentation.Controllers.Customers
}
}
[
HttpPost
(
"AddContactInfo"
)]
[
HttpPost
(
"AddContactInfo"
)]
[
Authorize
(
Roles
=
RolesNames
.
CUSTOMERS_PLANNER
)]
public
async
Task
<
IActionResult
>
PostContactInfo
(
AddContactInfoRequest
request
)
public
async
Task
<
IActionResult
>
PostContactInfo
(
AddContactInfoRequest
request
)
{
{
var
command
=
_mapper
.
Map
<
AddContactInfoCommand
>(
request
);
var
command
=
_mapper
.
Map
<
AddContactInfoCommand
>(
request
);
...
@@ -120,6 +129,7 @@ namespace PSManagement.Presentation.Controllers.Customers
...
@@ -120,6 +129,7 @@ namespace PSManagement.Presentation.Controllers.Customers
[
HttpPost
(
"RemoveContactInfo"
)]
[
HttpPost
(
"RemoveContactInfo"
)]
[
Authorize
(
Roles
=
RolesNames
.
CUSTOMERS_PLANNER
)]
public
async
Task
<
IActionResult
>
DeleteContactInfo
(
RemoveContactInfoRequest
request
)
public
async
Task
<
IActionResult
>
DeleteContactInfo
(
RemoveContactInfoRequest
request
)
{
{
var
command
=
_mapper
.
Map
<
RemoveContactInfoCommand
>(
request
);
var
command
=
_mapper
.
Map
<
RemoveContactInfoCommand
>(
request
);
...
...
PSManagement.Presentation/Controllers/Projects/ProjectsController.cs
View file @
fb047242
...
@@ -28,6 +28,8 @@ using PSManagement.Application.Projects.UseCases.Queries.GetParticipationChangeH
...
@@ -28,6 +28,8 @@ using PSManagement.Application.Projects.UseCases.Queries.GetParticipationChangeH
using
PSManagement.Application.Projects.UseCases.Queries.GetCompletionContribution
;
using
PSManagement.Application.Projects.UseCases.Queries.GetCompletionContribution
;
using
PSManagement.Application.Projects.UseCases.Commands.RemoveAttachment
;
using
PSManagement.Application.Projects.UseCases.Commands.RemoveAttachment
;
using
PSManagement.Application.Projects.UseCases.Queries.GetProjectCompletion
;
using
PSManagement.Application.Projects.UseCases.Queries.GetProjectCompletion
;
using
PSManagement.Domain.Identity.Constants
;
using
Microsoft.AspNetCore.Authorization
;
namespace
PSManagement.Presentation.Controllers.Projects
namespace
PSManagement.Presentation.Controllers.Projects
{
{
...
@@ -280,6 +282,7 @@ namespace PSManagement.Presentation.Controllers.Projects
...
@@ -280,6 +282,7 @@ namespace PSManagement.Presentation.Controllers.Projects
#
region
Propose
#
region
Propose
[
HttpPost
]
[
HttpPost
]
[
Authorize
(
Roles
=
RolesNames
.
SCIENTIFIC_DEPUTY
)]
public
async
Task
<
IActionResult
>
Post
([
FromBody
]
CreateProjectRequest
request
)
public
async
Task
<
IActionResult
>
Post
([
FromBody
]
CreateProjectRequest
request
)
{
{
var
command
=
_mapper
.
Map
<
CreateProjectCommand
>(
request
);
var
command
=
_mapper
.
Map
<
CreateProjectCommand
>(
request
);
...
...
PSManagement.Presentation/Controllers/Roles/RolesController.cs
View file @
fb047242
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
using
PSManagement.Application.Contracts.Authorization
;
using
PSManagement.Application.Contracts.Authorization
;
using
PSManagement.Domain.Identity.Constants
;
using
PSManagement.Presentation.Controllers.ApiBase
;
using
PSManagement.Presentation.Controllers.ApiBase
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
...
@@ -11,6 +12,7 @@ using System.Threading.Tasks;
...
@@ -11,6 +12,7 @@ using System.Threading.Tasks;
namespace
PSManagement.Presentation.Controllers.Roles
namespace
PSManagement.Presentation.Controllers.Roles
{
{
[
Route
(
"api/[controller]"
)]
[
Route
(
"api/[controller]"
)]
[
Authorize
(
Roles
=
RolesNames
.
ADMIN
)]
public
class
RolesController
:
APIController
public
class
RolesController
:
APIController
{
{
private
readonly
IRoleService
_roleService
;
private
readonly
IRoleService
_roleService
;
...
...
PSManagement.Presentation/Controllers/Roles/UserRolesController.cs
View file @
fb047242
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
using
PSManagement.Application.Contracts.Authorization
;
using
PSManagement.Application.Contracts.Authorization
;
using
PSManagement.Domain.Identity.Constants
;
using
PSManagement.Presentation.Controllers.ApiBase
;
using
PSManagement.Presentation.Controllers.ApiBase
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
...
@@ -11,6 +12,7 @@ using System.Threading.Tasks;
...
@@ -11,6 +12,7 @@ using System.Threading.Tasks;
namespace
PSManagement.Presentation.Controllers.Roles
namespace
PSManagement.Presentation.Controllers.Roles
{
{
[
Route
(
"api/[controller]"
)]
[
Route
(
"api/[controller]"
)]
[
Authorize
(
Roles
=
RolesNames
.
ADMIN
)]
public
class
UserRolesController
:
APIController
public
class
UserRolesController
:
APIController
{
{
private
readonly
IUserRoleService
_userRoleService
;
private
readonly
IUserRoleService
_userRoleService
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment