Report 'Invalid xsrfKey' as 'Not Signed In'
For Gerrit Code Review, an invalid xsrfKey in the JSON-RPC request really means that the server can't authenticate you. In our UI code that better translates to "not signed in". Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -18,13 +18,14 @@ import com.google.gerrit.client.ErrorDialog;
|
||||
import com.google.gerrit.client.Gerrit;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwtjsonrpc.client.JsonUtil;
|
||||
import com.google.gwtjsonrpc.client.RemoteJsonException;
|
||||
import com.google.gwtjsonrpc.client.ServerUnavailableException;
|
||||
|
||||
/** Abstract callback handling generic error conditions automatically */
|
||||
public abstract class GerritCallback<T> implements AsyncCallback<T> {
|
||||
public void onFailure(final Throwable caught) {
|
||||
if (isNotSignedIn(caught)) {
|
||||
if (isNotSignedIn(caught) || isInvalidXSRF(caught)) {
|
||||
new ErrorDialog(RpcConstants.C.errorNotSignedIn()).center();
|
||||
|
||||
} else if (isNoSuchEntity(caught)) {
|
||||
@@ -49,6 +50,11 @@ public abstract class GerritCallback<T> implements AsyncCallback<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isInvalidXSRF(final Throwable caught) {
|
||||
return caught instanceof RemoteJsonException
|
||||
&& caught.getMessage().equals(JsonUtil.ERROR_INVALID_XSRF);
|
||||
}
|
||||
|
||||
public static boolean isNotSignedIn(final Throwable caught) {
|
||||
if (caught instanceof NotSignedInException) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user