1
0
forked from PGL/Clyde

backend add ManageResearcherProfile

This commit is contained in:
2024-04-17 13:32:46 +02:00
parent 6116cbdaa4
commit e303048f7e
3 changed files with 20 additions and 3 deletions

View File

@ -1,5 +1,6 @@
package ovh.herisson.Clyde.EndPoints;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
@ -8,6 +9,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;
import ovh.herisson.Clyde.Services.AuthenticatorService;
import ovh.herisson.Clyde.Services.ScientificPublications.ResearchesService;
import ovh.herisson.Clyde.Tables.Applications;
import ovh.herisson.Clyde.Tables.Role;
import ovh.herisson.Clyde.Tables.User;
@ -20,7 +22,10 @@ public class ApplicationsController {
AuthenticatorService authServ;
public ApplicationsController(AuthenticatorService authServ){
ResearchesService researchesServ;
public ApplicationsController(AuthenticatorService authServ, ResearchesService researchesServ){
this.researchesServ = researchesServ;
this.authServ = authServ;
}
@ -47,7 +52,6 @@ public class ApplicationsController {
//if unAuthed
authorizedApps.add(Applications.Login);
authorizedApps.add(Applications.ResearcherProfile);
User user = authServ.getUserFromToken(token);
if(user == null)
@ -71,6 +75,9 @@ public class ApplicationsController {
if (!authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token)){
authorizedApps.add(Applications.UsersList);}
if (researchesServ.getResearcherByUser(user) != null)
authorizedApps.add(Applications.ManageResearcherProfile);
return authorizedApps;
}
}