Improve validation on api/users endpoints (#5752)

This commit is contained in:
Tom Moor
2023-08-31 18:06:18 -04:00
committed by GitHub
parent dec03b9d84
commit 7abb4f9ad6
15 changed files with 395 additions and 309 deletions

View File

@@ -7,8 +7,9 @@ import {
NotificationEventType,
UserPreference,
UserPreferences,
UserRole,
} from "@shared/types";
import type { Role, NotificationSettings } from "@shared/types";
import type { NotificationSettings } from "@shared/types";
import { client } from "~/utils/ApiClient";
import ParanoidModel from "./ParanoidModel";
import Field from "./decorators/Field";
@@ -74,13 +75,13 @@ class User extends ParanoidModel {
}
@computed
get role(): Role {
get role(): UserRole {
if (this.isAdmin) {
return "admin";
return UserRole.Admin;
} else if (this.isViewer) {
return "viewer";
return UserRole.Viewer;
} else {
return "member";
return UserRole.Member;
}
}