feat: fix postiz oauth

This commit is contained in:
Nevo David 2026-03-10 12:21:45 +07:00
parent 41fcb08834
commit 08c3143647

View file

@ -59,7 +59,7 @@ export class OAuthRepository {
});
}
updateApp(
async updateApp(
orgId: string,
data: {
name?: string;
@ -68,13 +68,17 @@ export class OAuthRepository {
redirectUrl?: string;
}
) {
return this._oauthApp.model.oAuthApp.update({
const app = await this._oauthApp.model.oAuthApp.findFirst({
where: {
organizationId_deletedAt: {
organizationId: orgId,
deletedAt: null,
},
organizationId: orgId,
deletedAt: null,
},
});
if (!app) {
return null;
}
return this._oauthApp.model.oAuthApp.update({
where: { id: app.id },
data,
include: {
picture: true,
@ -82,28 +86,36 @@ export class OAuthRepository {
});
}
deleteApp(orgId: string) {
return this._oauthApp.model.oAuthApp.update({
async deleteApp(orgId: string) {
const app = await this._oauthApp.model.oAuthApp.findFirst({
where: {
organizationId_deletedAt: {
organizationId: orgId,
deletedAt: null,
},
organizationId: orgId,
deletedAt: null,
},
});
if (!app) {
return null;
}
return this._oauthApp.model.oAuthApp.update({
where: { id: app.id },
data: {
deletedAt: new Date(),
},
});
}
updateClientSecret(orgId: string, newSecret: string) {
return this._oauthApp.model.oAuthApp.update({
async updateClientSecret(orgId: string, newSecret: string) {
const app = await this._oauthApp.model.oAuthApp.findFirst({
where: {
organizationId_deletedAt: {
organizationId: orgId,
deletedAt: null,
},
organizationId: orgId,
deletedAt: null,
},
});
if (!app) {
return null;
}
return this._oauthApp.model.oAuthApp.update({
where: { id: app.id },
data: {
clientSecret: newSecret,
},