Change registrar console login code in preparation for removing requireLogin

We are going to remove the requireLogin attribute from the action attribute, because it is specific to the UserService API. This is used by four actions:

ConsoleUIAction
RegistrarSettingsAction
RegistrarPaymentSetupAction
RegistrarPaymentAction

Instead, these four actions will now check the login status directly.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=159562335
This commit is contained in:
mountford 2017-06-20 08:16:43 -07:00 committed by Ben McIlwain
parent 17697388b8
commit 2b7f78db98
17 changed files with 151 additions and 112 deletions

View file

@ -42,6 +42,7 @@ import google.registry.request.HttpException.BadRequestException;
import google.registry.request.JsonActionRunner;
import google.registry.request.auth.Auth;
import google.registry.request.auth.AuthLevel;
import google.registry.request.auth.AuthResult;
import google.registry.security.JsonResponseHelper;
import google.registry.ui.forms.FormException;
import google.registry.ui.forms.FormFieldException;
@ -81,7 +82,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
@Inject HttpServletRequest request;
@Inject JsonActionRunner jsonActionRunner;
@Inject Registrar initialRegistrar;
@Inject AuthResult authResult;
@Inject SendEmailUtils sendEmailUtils;
@Inject SessionUtils sessionUtils;
@Inject @Config("registrarChangesNotificationEmailAddresses") ImmutableList<String>
@ -105,12 +106,9 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
throw new BadRequestException("Malformed JSON");
}
if (!sessionUtils.checkRegistrarConsoleLogin(request)) {
return JsonResponseHelper.create(ERROR, "Not authorized to access Registrar Console");
}
Registrar initialRegistrar = sessionUtils.getRegistrarForAuthResult(request, authResult);
// Process the operation. Though originally derived from a CRUD
// handlder, registrar-settings really only supports read and update.
// handler, registrar-settings really only supports read and update.
String op = Optional.fromNullable((String) input.get(OP_PARAM)).or("read");
@SuppressWarnings("unchecked")
Map<String, ?> args = (Map<String, Object>)