Use correct endpoint to lookup by username
This commit is contained in:
parent
85f706d48f
commit
f5e94f2069
2 changed files with 15 additions and 9 deletions
|
@ -691,6 +691,10 @@ export type ProfileType = Readonly<{
|
|||
badges?: unknown;
|
||||
}>;
|
||||
|
||||
export type AccountType = Readonly<{
|
||||
uuid?: string;
|
||||
}>;
|
||||
|
||||
export type GetIceServersResultType = Readonly<{
|
||||
username: string;
|
||||
password: string;
|
||||
|
@ -861,7 +865,7 @@ export type WebAPIType = {
|
|||
identifier: string,
|
||||
options: GetProfileOptionsType
|
||||
) => Promise<ProfileType>;
|
||||
getProfileForUsername: (username: string) => Promise<ProfileType>;
|
||||
getAccountForUsername: (username: string) => Promise<AccountType>;
|
||||
getProfileUnauth: (
|
||||
identifier: string,
|
||||
options: GetProfileUnauthOptionsType
|
||||
|
@ -1278,7 +1282,7 @@ export function initialize({
|
|||
getKeysForIdentifierUnauth,
|
||||
getMyKeys,
|
||||
getProfile,
|
||||
getProfileForUsername,
|
||||
getAccountForUsername,
|
||||
getProfileUnauth,
|
||||
getBadgeImageFile,
|
||||
getBoostBadgesFromServer,
|
||||
|
@ -1661,13 +1665,15 @@ export function initialize({
|
|||
})) as ProfileType;
|
||||
}
|
||||
|
||||
async function getProfileForUsername(usernameToFetch: string) {
|
||||
async function getAccountForUsername(usernameToFetch: string) {
|
||||
return (await _ajax({
|
||||
call: 'profile',
|
||||
call: 'username',
|
||||
httpType: 'GET',
|
||||
urlParameters: `/username/${encodeURIComponent(usernameToFetch)}`,
|
||||
urlParameters: `/${encodeURIComponent(usernameToFetch)}`,
|
||||
responseType: 'json',
|
||||
redactUrl: _createRedactor(usernameToFetch),
|
||||
unauthenticated: true,
|
||||
accessKey: undefined,
|
||||
})) as ProfileType;
|
||||
}
|
||||
|
||||
|
|
|
@ -143,15 +143,15 @@ async function checkForUsername(
|
|||
}
|
||||
|
||||
try {
|
||||
const profile = await server.getProfileForUsername(username);
|
||||
const account = await server.getAccountForUsername(username);
|
||||
|
||||
if (!profile.uuid) {
|
||||
log.error("checkForUsername: Returned profile didn't include a uuid");
|
||||
if (!account.uuid) {
|
||||
log.error("checkForUsername: Returned account didn't include a uuid");
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
uuid: UUID.cast(profile.uuid),
|
||||
uuid: UUID.cast(account.uuid),
|
||||
username,
|
||||
};
|
||||
} catch (error) {
|
||||
|
|
Loading…
Add table
Reference in a new issue