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;
|
badges?: unknown;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
export type AccountType = Readonly<{
|
||||||
|
uuid?: string;
|
||||||
|
}>;
|
||||||
|
|
||||||
export type GetIceServersResultType = Readonly<{
|
export type GetIceServersResultType = Readonly<{
|
||||||
username: string;
|
username: string;
|
||||||
password: string;
|
password: string;
|
||||||
|
@ -861,7 +865,7 @@ export type WebAPIType = {
|
||||||
identifier: string,
|
identifier: string,
|
||||||
options: GetProfileOptionsType
|
options: GetProfileOptionsType
|
||||||
) => Promise<ProfileType>;
|
) => Promise<ProfileType>;
|
||||||
getProfileForUsername: (username: string) => Promise<ProfileType>;
|
getAccountForUsername: (username: string) => Promise<AccountType>;
|
||||||
getProfileUnauth: (
|
getProfileUnauth: (
|
||||||
identifier: string,
|
identifier: string,
|
||||||
options: GetProfileUnauthOptionsType
|
options: GetProfileUnauthOptionsType
|
||||||
|
@ -1278,7 +1282,7 @@ export function initialize({
|
||||||
getKeysForIdentifierUnauth,
|
getKeysForIdentifierUnauth,
|
||||||
getMyKeys,
|
getMyKeys,
|
||||||
getProfile,
|
getProfile,
|
||||||
getProfileForUsername,
|
getAccountForUsername,
|
||||||
getProfileUnauth,
|
getProfileUnauth,
|
||||||
getBadgeImageFile,
|
getBadgeImageFile,
|
||||||
getBoostBadgesFromServer,
|
getBoostBadgesFromServer,
|
||||||
|
@ -1661,13 +1665,15 @@ export function initialize({
|
||||||
})) as ProfileType;
|
})) as ProfileType;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getProfileForUsername(usernameToFetch: string) {
|
async function getAccountForUsername(usernameToFetch: string) {
|
||||||
return (await _ajax({
|
return (await _ajax({
|
||||||
call: 'profile',
|
call: 'username',
|
||||||
httpType: 'GET',
|
httpType: 'GET',
|
||||||
urlParameters: `/username/${encodeURIComponent(usernameToFetch)}`,
|
urlParameters: `/${encodeURIComponent(usernameToFetch)}`,
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
redactUrl: _createRedactor(usernameToFetch),
|
redactUrl: _createRedactor(usernameToFetch),
|
||||||
|
unauthenticated: true,
|
||||||
|
accessKey: undefined,
|
||||||
})) as ProfileType;
|
})) as ProfileType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,15 +143,15 @@ async function checkForUsername(
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const profile = await server.getProfileForUsername(username);
|
const account = await server.getAccountForUsername(username);
|
||||||
|
|
||||||
if (!profile.uuid) {
|
if (!account.uuid) {
|
||||||
log.error("checkForUsername: Returned profile didn't include a uuid");
|
log.error("checkForUsername: Returned account didn't include a uuid");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
uuid: UUID.cast(profile.uuid),
|
uuid: UUID.cast(account.uuid),
|
||||||
username,
|
username,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue