mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Github: correct check on fresh config
This commit is contained in:
@@ -53,7 +53,7 @@ public class GithubSettings implements PersistentStateComponent<GithubSettings.S
|
||||
public static class State {
|
||||
public String LOGIN = "";
|
||||
public String HOST = GithubApiUtil.DEFAULT_GITHUB_HOST;
|
||||
public AuthType AUTH_TYPE = AuthType.BASIC;
|
||||
public AuthType AUTH_TYPE = AuthType.ANONYMOUS;
|
||||
public boolean ANONYMOUS_GIST = false;
|
||||
public boolean OPEN_IN_BROWSER_GIST = true;
|
||||
public boolean PRIVATE_GIST = true;
|
||||
@@ -166,6 +166,7 @@ public class GithubSettings implements PersistentStateComponent<GithubSettings.S
|
||||
case TOKEN:
|
||||
return GithubAuthData.createTokenAuth(getHost(), getPassword());
|
||||
case ANONYMOUS:
|
||||
return GithubAuthData.createAnonymous();
|
||||
default:
|
||||
throw new IllegalStateException("GithubSettings: getAuthData - wrong AuthType: " + getAuthType());
|
||||
}
|
||||
@@ -184,6 +185,8 @@ public class GithubSettings implements PersistentStateComponent<GithubSettings.S
|
||||
setPassword(auth.getTokenAuth().getToken(), rememberPassword);
|
||||
break;
|
||||
case ANONYMOUS:
|
||||
setPassword("", rememberPassword);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("GithubSettings: setAuthData - wrong AuthType: " + getAuthType());
|
||||
}
|
||||
|
||||
@@ -63,6 +63,9 @@ public class GithubUtil {
|
||||
@NotNull ThrowableConsumer<GithubAuthData, IOException> task) throws IOException {
|
||||
GithubAuthData auth = GithubSettings.getInstance().getAuthData();
|
||||
try {
|
||||
if (auth.getAuthType() == GithubAuthData.AuthType.ANONYMOUS) {
|
||||
throw new AuthenticationException("Settings authentication not set");
|
||||
}
|
||||
task.consume(auth);
|
||||
return auth;
|
||||
}
|
||||
@@ -94,6 +97,9 @@ public class GithubUtil {
|
||||
@NotNull ThrowableConvertor<GithubAuthData, T, IOException> task) throws IOException {
|
||||
GithubAuthData auth = GithubSettings.getInstance().getAuthData();
|
||||
try {
|
||||
if (auth.getAuthType() == GithubAuthData.AuthType.ANONYMOUS) {
|
||||
throw new AuthenticationException("Settings authentication not set");
|
||||
}
|
||||
return task.convert(auth);
|
||||
}
|
||||
catch (AuthenticationException e) {
|
||||
|
||||
Reference in New Issue
Block a user