Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added in Staff Role Permissions #38

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/main/java/com/apc/luthercourseproposal/ApcController.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public class ApcController extends HttpServlet {
private static final String ROLE_ADMIN = "apc_development";
private static final String ROLE_FACULTY = "Faculty";
private static final String ROLE_REGISTRAR = "Registrars_Office";
private static final String ROLE_STAFF = "apc_staff";

/**
* Handles the HTTP requests. Switches based on method type, and handles
Expand Down Expand Up @@ -152,6 +153,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
if (request.isUserInRole(ROLE_FACULTY)) {
roleBuilder.add(ROLE_FACULTY);
}
if (request.isUserInRole(ROLE_STAFF)) {
roleBuilder.add(ROLE_STAFF);
}
JsonArray roles = roleBuilder.build();

ServletContext sc = getServletContext();
Expand Down Expand Up @@ -286,11 +290,14 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
if (request.isUserInRole(ROLE_FACULTY)) {
roles.add(ROLE_FACULTY);
}
if (request.isUserInRole(ROLE_STAFF)) {
roles.add(ROLE_STAFF);
}

switch(data.getString("q")){
case "create":
try{
if (!roles.contains(ROLE_ADMIN) && !roles.contains(ROLE_FACULTY)) {
if (!roles.contains(ROLE_ADMIN) && !roles.contains(ROLE_FACULTY) && !roles.contains(ROLE_STAFF)) {
throw new Exception("User is not allowed to create a proposal - contact admin for priveleges.");
}
resp = this.dao.createProposal(data.getJsonObject("d"));
Expand All @@ -313,7 +320,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
break;
case "save":
try{
if (!roles.contains(ROLE_ADMIN) && !roles.contains(ROLE_FACULTY)) {
if (!roles.contains(ROLE_ADMIN) && !roles.contains(ROLE_FACULTY) && !roles.contains(ROLE_STAFF)) {
throw new Exception("User is not allowed to update proposals - contact admin for priveleges.");
}
resp = this.dao.saveProposal(data.getJsonObject("d"));
Expand Down
4 changes: 4 additions & 0 deletions src/main/webapp/META-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<role-name>apc_development</role-name>
<role-name>Faculty</role-name>
<role-name>Registrars_Office</role-name>
<role-name>apc_staff</role-name>
</auth-constraint>
</security-constraint>

Expand All @@ -44,6 +45,9 @@
<security-role>
<role-name>Registrars_Office</role-name>
</security-role>
<security-role>
<role-name>apc_staff</role-name>
</security-role>

<login-config>
<auth-method>FORM</auth-method>
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/templates/dashboard.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="dashboard container-fluid">
<div class="col-md-6">
<div ng-hide="user.role.length ==1 && user.role.indexOf( 'Registrars_Office' ) != -1" class="container-fluid jumbotron">
<div ng-hide="user.role.length == 1 && user.role.indexOf( 'Registrars_Office' ) != -1" class="container-fluid jumbotron">
<course-list data='myChanges' user='user' courses="courses" proposals="allProposals"></course-list>
</div>
<div ng-hide="user.role.length ==1 && user.role.indexOf( 'Registrars_Office' ) != -1" class="container-fluid jumbotron">
Expand Down