mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
refactor(api): ♻️ Remove useless authorization checks
This commit is contained in:
parent
dc12b269f5
commit
09f30db83a
59 changed files with 103 additions and 839 deletions
|
|
@ -40,14 +40,6 @@ export default (plugin: PluginType): void => {
|
|||
},
|
||||
},
|
||||
},
|
||||
401: {
|
||||
description: "Unauthorized",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: ErrorSchema,
|
||||
},
|
||||
},
|
||||
},
|
||||
404: {
|
||||
description: "Account not found",
|
||||
content: {
|
||||
|
|
@ -62,10 +54,6 @@ export default (plugin: PluginType): void => {
|
|||
const { id: issuerId } = context.req.valid("param");
|
||||
const { user } = context.get("auth");
|
||||
|
||||
if (!user) {
|
||||
throw new ApiError(401, "Unauthorized");
|
||||
}
|
||||
|
||||
const issuer = context
|
||||
.get("pluginConfig")
|
||||
.providers.find((provider) => provider.id === issuerId);
|
||||
|
|
@ -126,14 +114,6 @@ export default (plugin: PluginType): void => {
|
|||
204: {
|
||||
description: "Account unlinked",
|
||||
},
|
||||
401: {
|
||||
description: "Unauthorized",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: ErrorSchema,
|
||||
},
|
||||
},
|
||||
},
|
||||
404: {
|
||||
description: "Account not found",
|
||||
content: {
|
||||
|
|
@ -148,10 +128,6 @@ export default (plugin: PluginType): void => {
|
|||
const { id: issuerId } = context.req.valid("param");
|
||||
const { user } = context.get("auth");
|
||||
|
||||
if (!user) {
|
||||
throw new ApiError(401, "Unauthorized");
|
||||
}
|
||||
|
||||
// Check if issuer exists
|
||||
const issuer = context
|
||||
.get("pluginConfig")
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import {
|
|||
generateRandomCodeVerifier,
|
||||
} from "oauth4webapi";
|
||||
import { z } from "zod";
|
||||
import { ApiError } from "~/classes/errors/api-error.ts";
|
||||
import { ErrorSchema } from "~/types/api";
|
||||
import type { PluginType } from "../../index.ts";
|
||||
import { oauthDiscoveryRequest, oauthRedirectUri } from "../../utils.ts";
|
||||
|
|
@ -40,23 +39,11 @@ export default (plugin: PluginType): void => {
|
|||
},
|
||||
},
|
||||
},
|
||||
401: {
|
||||
description: "Unauthorized",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: ErrorSchema,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
async (context) => {
|
||||
const { user } = context.get("auth");
|
||||
|
||||
if (!user) {
|
||||
throw new ApiError(401, "Unauthorized");
|
||||
}
|
||||
|
||||
const linkedAccounts = await user.getLinkedOidcAccounts(
|
||||
context.get("pluginConfig").providers,
|
||||
);
|
||||
|
|
@ -99,14 +86,6 @@ export default (plugin: PluginType): void => {
|
|||
302: {
|
||||
description: "Redirect to OpenID provider",
|
||||
},
|
||||
401: {
|
||||
description: "Unauthorized",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: ErrorSchema,
|
||||
},
|
||||
},
|
||||
},
|
||||
404: {
|
||||
description: "Issuer not found",
|
||||
content: {
|
||||
|
|
@ -120,10 +99,6 @@ export default (plugin: PluginType): void => {
|
|||
async (context) => {
|
||||
const { user } = context.get("auth");
|
||||
|
||||
if (!user) {
|
||||
throw new ApiError(401, "Unauthorized");
|
||||
}
|
||||
|
||||
const { issuer: issuerId } = context.req.valid("json");
|
||||
|
||||
const issuer = context
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue