-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#9 Implemented support for admin password change use case.
- Loading branch information
Showing
8 changed files
with
306 additions
and
30 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/main/java/br/gov/sibbr/api/controller/AdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package br.gov.sibbr.api.controller; | ||
|
||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import br.gov.sibbr.api.service.AuthService; | ||
|
||
/** | ||
* Controller responsible for managing URL requests and calling for services to | ||
* provide administrative operations | ||
* | ||
* @author Pedro Guimarães | ||
* | ||
*/ | ||
@RestController | ||
public class AdminController { | ||
|
||
AuthService authService = new AuthService(); | ||
|
||
// Method responsible for providing the list of all users | ||
@RequestMapping(value = "/admin/users", method = RequestMethod.GET) | ||
public String listUsers(@RequestParam(value = "token", defaultValue = "null") String token, Model model) { | ||
String message = authService.checkTokenAdmin(token); | ||
// Something went wrong. Display error message. | ||
if (message != null) { | ||
model.addAttribute("error", message); | ||
} | ||
// Proper admin identification, display | ||
return "users"; | ||
} | ||
|
||
// Method responsible for providing the list of all users | ||
@RequestMapping(value = "/admin/users/authorized", method = RequestMethod.GET) | ||
public String listAuthorizedUsers(@RequestParam(value = "token", defaultValue = "null") String token, Model model) { | ||
String message = authService.checkTokenAdmin(token); | ||
// Something went wrong. Display error message. | ||
if (message != null) { | ||
model.addAttribute("error", message); | ||
} | ||
// Proper admin identification, display | ||
return "users"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package br.gov.sibbr.api.model; | ||
|
||
/** | ||
* Class to model a POJO for an api_user instance | ||
* | ||
* @author Pedro Guimarães | ||
* | ||
*/ | ||
public class ApiUserResult { | ||
|
||
private Long auto_id; | ||
private String email; | ||
private Boolean authorized; | ||
|
||
/** | ||
* Default class constructor | ||
* @param auto_id | ||
* @param email | ||
* @param authorized | ||
*/ | ||
public ApiUserResult(Long auto_id, String email, Boolean authorized) { | ||
this.auto_id = auto_id; | ||
this.email = email; | ||
this.authorized = authorized; | ||
} | ||
|
||
public Long getAuto_id() { | ||
return auto_id; | ||
} | ||
|
||
public void setAuto_id(Long auto_id) { | ||
this.auto_id = auto_id; | ||
} | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
public void setEmail(String email) { | ||
this.email = email; | ||
} | ||
|
||
public Boolean getAuthorized() { | ||
return authorized; | ||
} | ||
|
||
public void setAuthorized(Boolean authorized) { | ||
this.authorized = authorized; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.