mirror of
https://github.com/versia-pub/frontend.git
synced 2026-03-13 11:39:16 +01:00
refactor: ♻️ Fix linter errors
This commit is contained in:
parent
8a984abfb2
commit
f9433e259b
30 changed files with 235 additions and 157 deletions
|
|
@ -111,14 +111,14 @@ const hostname = useRequestURL().hostname;
|
|||
const query = new URLSearchParams(
|
||||
window?.location.search ?? useRequestURL().search,
|
||||
);
|
||||
const redirect_uri = query.get("redirect_uri");
|
||||
const response_type = query.get("response_type");
|
||||
const client_id = query.get("client_id");
|
||||
const redirectUri = query.get("redirect_uri");
|
||||
const responseType = query.get("response_type");
|
||||
const clientId = query.get("client_id");
|
||||
const scope = query.get("scope");
|
||||
const error = query.get("error");
|
||||
const error_description = query.get("error_description");
|
||||
const errorDescription = query.get("error_description");
|
||||
|
||||
const validUrlParameters = redirect_uri && response_type && client_id && scope;
|
||||
const validUrlParameters = redirectUri && responseType && clientId && scope;
|
||||
|
||||
const ssoConfig = useSSOConfig();
|
||||
</script>
|
||||
|
|
@ -92,11 +92,11 @@ const application = query.application;
|
|||
const website = query.website
|
||||
? decodeURIComponent(query.website as string)
|
||||
: null;
|
||||
const redirect_uri = query.redirect_uri as string;
|
||||
const client_id = query.client_id;
|
||||
const redirectUri = query.redirect_uri as string;
|
||||
const clientId = query.client_id;
|
||||
const scope = query.scope ? decodeURIComponent(query.scope as string) : "";
|
||||
|
||||
const validUrlParameters = application && redirect_uri && client_id && scope;
|
||||
const validUrlParameters = application && redirectUri && clientId && scope;
|
||||
|
||||
const oauthScopeText: Record<string, string> = {
|
||||
"rw:accounts": "$VERB your account information",
|
||||
|
|
@ -123,7 +123,7 @@ const scopes = scope.split(" ");
|
|||
// Return an array of strings to display
|
||||
// "read write:accounts" returns all the fields with $VERB as read, plus the accounts field with $VERB as write
|
||||
const getScopeText = (fullScopes: string[]) => {
|
||||
const scopeTexts = [];
|
||||
const scopeTexts: string[][] = [];
|
||||
|
||||
const readScopes = fullScopes.filter((scope) => scope.includes("read"));
|
||||
const writeScopes = fullScopes.filter((scope) => scope.includes("write"));
|
||||
|
|
@ -138,12 +138,14 @@ const getScopeText = (fullScopes: string[]) => {
|
|||
(writeScopes.includes(`write:${scopeName}`) ||
|
||||
writeScopes.find((scope) => scope === "write"))
|
||||
) {
|
||||
if (oauthScopeText[possibleScope]?.includes("$VERB"))
|
||||
if (oauthScopeText[possibleScope]?.includes("$VERB")) {
|
||||
scopeTexts.push([
|
||||
"Read and write",
|
||||
oauthScopeText[possibleScope]?.replace("$VERB", ""),
|
||||
oauthScopeText[possibleScope]?.replace("$VERB", "") ?? "",
|
||||
]);
|
||||
else scopeTexts.push(["", oauthScopeText[possibleScope]]);
|
||||
} else {
|
||||
scopeTexts.push(["", oauthScopeText[possibleScope] ?? ""]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -152,12 +154,14 @@ const getScopeText = (fullScopes: string[]) => {
|
|||
(readScopes.includes(`read:${scopeName}`) ||
|
||||
readScopes.find((scope) => scope === "read"))
|
||||
) {
|
||||
if (oauthScopeText[possibleScope]?.includes("$VERB"))
|
||||
if (oauthScopeText[possibleScope]?.includes("$VERB")) {
|
||||
scopeTexts.push([
|
||||
"Read",
|
||||
oauthScopeText[possibleScope]?.replace("$VERB", ""),
|
||||
oauthScopeText[possibleScope]?.replace("$VERB", "") ?? "",
|
||||
]);
|
||||
else scopeTexts.push(["", oauthScopeText[possibleScope]]);
|
||||
} else {
|
||||
scopeTexts.push(["", oauthScopeText[possibleScope] ?? ""]);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
|
|
@ -165,12 +169,14 @@ const getScopeText = (fullScopes: string[]) => {
|
|||
(writeScopes.includes(`write:${scopeName}`) ||
|
||||
writeScopes.find((scope) => scope === "write"))
|
||||
) {
|
||||
if (oauthScopeText[possibleScope]?.includes("$VERB"))
|
||||
if (oauthScopeText[possibleScope]?.includes("$VERB")) {
|
||||
scopeTexts.push([
|
||||
"Write",
|
||||
oauthScopeText[possibleScope]?.replace("$VERB", ""),
|
||||
oauthScopeText[possibleScope]?.replace("$VERB", "") ?? "",
|
||||
]);
|
||||
else scopeTexts.push(["", oauthScopeText[possibleScope]]);
|
||||
} else {
|
||||
scopeTexts.push(["", oauthScopeText[possibleScope] ?? ""]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return scopeTexts;
|
||||
|
|
|
|||
|
|
@ -99,14 +99,14 @@ const query = new URLSearchParams(
|
|||
window?.location.search ?? useRequestURL().search,
|
||||
);
|
||||
const token = query.get("token");
|
||||
const login_reset = query.get("login_reset") === "true";
|
||||
const loginReset = query.get("login_reset") === "true";
|
||||
const success = query.get("success") === "true";
|
||||
let error = query.get("error");
|
||||
let error_description = query.get("error_description");
|
||||
let errorDescription = query.get("error_description");
|
||||
|
||||
if (login_reset) {
|
||||
if (loginReset) {
|
||||
error = "Login reset";
|
||||
error_description =
|
||||
errorDescription =
|
||||
"Your password has been reset by an administrator. Please change it here.";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue