mirror of
https://github.com/google/nomulus.git
synced 2025-07-11 21:48:18 +02:00
Fix bug which caused exceptions when attempting to redirect to the console login page
When the registrar console code determines that a user has not logged in, it redirects to a login page. But when authenticating as an internal request (which should never happen), the redirection code encountered an exception, resulting in a 500 error. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=163867018
This commit is contained in:
parent
2a29ada032
commit
5fefa8906d
2 changed files with 33 additions and 1 deletions
|
@ -82,7 +82,19 @@ public final class ConsoleUiAction implements Runnable {
|
|||
public void run() {
|
||||
if (!authResult.userAuthInfo().isPresent()) {
|
||||
response.setStatus(SC_MOVED_TEMPORARILY);
|
||||
response.setHeader(LOCATION, userService.createLoginURL(req.getRequestURI()));
|
||||
String location;
|
||||
try {
|
||||
location = userService.createLoginURL(req.getRequestURI());
|
||||
} catch (IllegalArgumentException e) {
|
||||
// UserServiceImpl.createLoginURL() throws IllegalArgumentException if underlying API call
|
||||
// returns an error code of NOT_ALLOWED. createLoginURL() assumes that the error is caused
|
||||
// by an invalid URL. But in fact, the error can also occur if UserService doesn't have any
|
||||
// user information, which happens when the request has been authenticated as internal. In
|
||||
// this case, we want to avoid dying before we can send the redirect, so just redirect to
|
||||
// the root path.
|
||||
location = "/";
|
||||
}
|
||||
response.setHeader(LOCATION, location);
|
||||
return;
|
||||
}
|
||||
User user = authResult.userAuthInfo().get().user();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue