Skip to content

Commit

Permalink
Renamed account.{disabled->is_disabled}
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Nov 9, 2023
1 parent e7d0aef commit c74eb94
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface AccountResult {
oplvl: AccountType;
lastchange: string;
created: string;
disabled: boolean;
is_disabled: boolean;
token?: string;
session?: string;
}
Expand Down Expand Up @@ -105,7 +105,7 @@ export interface Account {
/**
* If the account is currently disabled
*/
disabled: boolean;
is_disabled: boolean;

/**
* The login token of the account
Expand Down Expand Up @@ -140,7 +140,7 @@ function parseAccount<A extends Account>(result: AccountResult): A {
oplvl: result?.oplvl,
lastchange: new Date(result?.lastchange),
created: new Date(result?.created),
disabled: result?.disabled,
is_disabled: result?.is_disabled,
};
if ('token' in result) {
parsed.token = result.token;
Expand Down Expand Up @@ -193,7 +193,7 @@ export function stripAccountInfo(account: Account, access: Access = Access.PUBLI
oplvl: account.oplvl,
lastchange: account.lastchange,
created: account.created,
disabled: account.disabled,
is_disabled: account.is_disabled,
};
if (access == Access.PUBLIC) {
return info;
Expand Down Expand Up @@ -240,7 +240,7 @@ export function checkAccountAttribute<K extends keyof FullAccount>(key: K, value
if (_value.length != 64) throw new Error('Invalid token or session');
if (!/^[0-9a-f]+$/.test(_value)) throw new Error('Invalid token or session');
break;
case 'disabled':
case 'is_disabled':
if (![true, false, 1, 0, 'true', 'false'].some(v => v === _value)) throw new Error('Invalid disabled value');
break;
case 'password':
Expand Down Expand Up @@ -383,8 +383,8 @@ export async function update<K extends keyof FullAccount>(id: string, key: K, va
* @returns True when successful
*/
export async function disable(id: string, reason?: string): Promise<boolean> {
const account = await update(id, 'disabled', true, reason);
return account.disabled;
const account = await update(id, 'is_disabled', true, reason);
return account.is_disabled;
}

/**
Expand All @@ -394,6 +394,6 @@ export async function disable(id: string, reason?: string): Promise<boolean> {
* @returns True when successful
*/
export async function enable(id: string, reason?: string): Promise<boolean> {
const account = await update(id, 'disabled', false, reason);
return !account.disabled;
const account = await update(id, 'is_disabled', false, reason);
return !account.is_disabled;
}

0 comments on commit c74eb94

Please sign in to comment.