Skip to content

Commit 337220c

Browse files
TCA-853 Clean up DICE store #time 15m
1 parent c9cb23b commit 337220c

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export {
2-
getDiceStatusAsync as userStoreGetDiceStatusAsync,
2+
getMfaStatusAsync as userStoreGetMfaStatusAsync,
33
patchAsync as userStorePatchAsync,
44
} from './user-xhr.store'
55
export { type UserPatchRequest } from './user-xhr.store'

src-ts/lib/functions/user-functions/user-store/user-xhr.store.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ import { xhrGetAsync, xhrPatchAsync } from '../../xhr-functions'
33

44
import { user as userEndpoint } from './user-endpoint.config'
55

6+
export interface MfaStatusResult {
7+
result: {
8+
content: {
9+
diceEnabled: boolean
10+
mfaEnabled: boolean
11+
}
12+
}
13+
}
14+
615
export interface UserPatchRequest {
716
param: {
817
credential: {
@@ -12,20 +21,8 @@ export interface UserPatchRequest {
1221
}
1322
}
1423

15-
export async function getDiceStatusAsync(userId: number): Promise<boolean> {
16-
17-
interface DiceStatusResult {
18-
result: {
19-
content: {
20-
mfaEnabled: boolean
21-
diceEnabled: boolean
22-
}
23-
}
24-
}
25-
const result: DiceStatusResult
26-
= await xhrGetAsync<DiceStatusResult>(`${userEndpoint(userId)}/2fa`)
27-
28-
return !!result.result.content.mfaEnabled && !!result.result.content.diceEnabled
24+
export async function getMfaStatusAsync(userId: number): Promise<MfaStatusResult> {
25+
return xhrGetAsync<MfaStatusResult>(`${userEndpoint(userId)}/2fa`)
2926
}
3027

3128
export async function patchAsync(userId: number, request: UserPatchRequest): Promise<User> {

src-ts/lib/functions/user-functions/user.functions.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { UserPatchRequest, userStoreGetDiceStatusAsync, userStorePatchAsync } from './user-store'
1+
import { UserPatchRequest, userStoreGetMfaStatusAsync, userStorePatchAsync } from './user-store'
2+
import { MfaStatusResult } from './user-store/user-xhr.store'
23

34
export async function getDiceStatusAsync(userId: number): Promise<boolean> {
4-
return userStoreGetDiceStatusAsync(userId)
5+
const result: MfaStatusResult = await userStoreGetMfaStatusAsync(userId)
6+
return !!result.result.content.mfaEnabled && !!result.result.content.diceEnabled
57
}
68

79
export async function updatePasswordAsync(userId: number, currentPassword: string, password: string): Promise<void> {

0 commit comments

Comments
 (0)