mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Github: add getCurrentUser function
This commit is contained in:
@@ -212,7 +212,7 @@ public class GithubShareAction extends DumbAwareAction {
|
||||
}
|
||||
|
||||
// check access to private repos (network)
|
||||
final GithubUserDetailed userInfo = GithubApiUtil.getCurrentUserInfo(auth);
|
||||
final GithubUserDetailed userInfo = GithubApiUtil.getCurrentUserDetailed(auth);
|
||||
githubInfoRef.set(new GithubInfo(auth, userInfo, names));
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
@@ -232,7 +232,7 @@ public class GithubUtil {
|
||||
}
|
||||
|
||||
private static void testConnection(@NotNull GithubAuthData auth, @Nullable String login) throws IOException {
|
||||
GithubUserDetailed user = GithubApiUtil.getCurrentUserInfo(auth);
|
||||
GithubUserDetailed user = GithubApiUtil.getCurrentUserDetailed(auth);
|
||||
if (login != null && !login.equalsIgnoreCase(user.getLogin())) {
|
||||
throw new GithubAuthenticationException("Wrong login");
|
||||
}
|
||||
|
||||
@@ -404,7 +404,13 @@ public class GithubApiUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static GithubUserDetailed getCurrentUserInfo(@NotNull GithubAuthData auth) throws IOException {
|
||||
public static GithubUser getCurrentUser(@NotNull GithubAuthData auth) throws IOException {
|
||||
JsonElement result = getRequest(auth, "/user");
|
||||
return createDataFromRaw(fromJson(result, GithubUserRaw.class), GithubUser.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static GithubUserDetailed getCurrentUserDetailed(@NotNull GithubAuthData auth) throws IOException {
|
||||
JsonElement result = getRequest(auth, "/user");
|
||||
return createDataFromRaw(fromJson(result, GithubUserRaw.class), GithubUserDetailed.class);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user