Page MenuHomeSealhub

username.ts
No OneTemporary

Authored By
Unknown
Size
769 B
Referenced Files
None
Subscribers
None

username.ts

import 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, new_value: string, old_value: string) {
if (old_value === new_value) {
return Field.valid();
}
if (me_synonyms.indexOf(new_value) !== -1) {
return Field.invalid(
`'${new_value}' is a reserved keyword. Please pick another username.`
);
}
const response = await this.app.collections.users
.suList()
.filter({ username: new_value })
.fetch();
if (!response.empty) {
return Field.invalid("Username already taken");
}
return Field.valid();
}
}

File Metadata

Mime Type
application/javascript
Expires
Fri, Nov 27, 17:24 (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1229031
Default Alt Text
username.ts (769 B)

Event Timeline