Files
outline/app/models/oauth/OAuthAuthentication.ts
T
Tom Moor 57c110dbe5 chore: Upgrade MobX (#13554)
* Upgrade Mobx

* fix: Enforce MobX action boundaries

* fix: Wrap static observable updates in actions

* Remove iteration tests
2026-09-02 20:31:37 -04:00

45 lines
1.0 KiB
TypeScript

import { action, observable } from "mobx";
import { client } from "~/utils/ApiClient";
import User from "../User";
import Field from "../decorators/Field";
import Relation from "../decorators/Relation";
import type OAuthClient from "./OAuthClient";
import Model from "../base/Model";
class OAuthAuthentication extends Model {
static modelName = "OAuthAuthentication";
constructor(fields: Record<string, unknown>, store: Model["store"]) {
super(fields, store);
this.initialize(fields);
}
/** A list of scopes that this authentication has access to */
@Field
@observable
scope: string[];
@Relation(() => User)
user: User;
userId: string;
oauthClient: Pick<OAuthClient, "id" | "name" | "clientId" | "avatarUrl">;
oauthClientId: string;
lastActiveAt: string;
@action
public async deleteAll() {
await client.post(`/${this.store.apiEndpoint}.delete`, {
oauthClientId: this.oauthClientId,
scope: this.scope,
});
return this.store.remove(this.id);
}
}
export default OAuthAuthentication;