Skip to content

Commit dbd9b30

Browse files
committed
Refactor to use generated types
1 parent 2a180d4 commit dbd9b30

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

site/src/api/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const getAuthMethods = async (): Promise<TypesGen.AuthMethods> => {
7676
return response.data
7777
}
7878

79-
export const getUserPermissions = async (
79+
export const checkUserPermissions = async (
8080
userId: string,
8181
params: TypesGen.UserPermissionCheckRequest,
8282
): Promise<TypesGen.UserPermissionCheckResponse> => {

site/src/api/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ export interface ReconnectingPTYRequest {
1010
readonly height?: number
1111
readonly width?: number
1212
}
13-
14-
export type UserPermissionCheckResponse = Record<string, boolean>

site/src/xServices/auth/authXService.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export interface AuthContext {
2323
updateProfileError?: Error | unknown
2424
me?: TypesGen.User
2525
methods?: TypesGen.AuthMethods
26-
permissions?: Types.UserPermissionCheckResponse
27-
getPermissionsError?: Error | unknown
26+
permissions?: TypesGen.UserPermissionCheckResponse
27+
checkPermissionsError?: Error | unknown
2828
}
2929

3030
export type AuthEvent =
@@ -61,8 +61,8 @@ export const authMachine =
6161
updateProfile: {
6262
data: TypesGen.User
6363
}
64-
getPermissions: {
65-
data: Types.UserPermissionCheckResponse
64+
checkPermissions: {
65+
data: TypesGen.UserPermissionCheckResponse
6666
}
6767
},
6868
},
@@ -117,8 +117,8 @@ export const authMachine =
117117
gettingPermissions: {
118118
entry: "clearGetPermissionsError",
119119
invoke: {
120-
src: "getPermissions",
121-
id: "getPermissions",
120+
src: "checkPermissions",
121+
id: "checkPermissions",
122122
onDone: [
123123
{
124124
actions: ["assignPermissions"],
@@ -234,12 +234,12 @@ export const authMachine =
234234

235235
return API.updateProfile(context.me.id, event.data)
236236
},
237-
getPermissions: async (context) => {
237+
checkPermissions: async (context) => {
238238
if (!context.me) {
239239
throw new Error("No current user found")
240240
}
241241

242-
return API.getUserPermissions(context.me.id, {
242+
return API.checkUserPermissions(context.me.id, {
243243
checks: permissionsToCheck,
244244
})
245245
},
@@ -289,10 +289,10 @@ export const authMachine =
289289
permissions: (_, event) => event.data,
290290
}),
291291
assignGetPermissionsError: assign({
292-
getPermissionsError: (_, event) => event.data,
292+
checkPermissionsError: (_, event) => event.data,
293293
}),
294294
clearGetPermissionsError: assign({
295-
getPermissionsError: (_) => undefined,
295+
checkPermissionsError: (_) => undefined,
296296
}),
297297
},
298298
},

0 commit comments

Comments
 (0)