Page MenuHomeSealhub

username.ts
No OneTemporary

username.ts

import type Context from "../../../context";
import { Field } from "../../../main";
import me_synonyms from "../../../misc/me-synonyms";
import TextStorage from "./text-storage";
export default class Username extends TextStorage {
typeName = "username";
async isProperValue(
context: Context,
new_value: string,
old_value: string
) {
if (old_value === new_value) {
return Field.valid();
}
if (me_synonyms.indexOf(new_value) !== -1) {
return Field.invalid(
context.app.i18n("invalid_username", [new_value])
);
}
const response = await this.app.collections.users
.suList()
.filter({ username: new_value })
.fetch();
if (!response.empty) {
return Field.invalid(context.app.i18n("username_taken"));
}
return Field.valid();
}
}

File Metadata

Mime Type
text/x-java
Expires
Tue, Jul 8, 07:59 (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
798867
Default Alt Text
username.ts (779 B)

Event Timeline