Prevent username reusing
This commit is contained in:
parent
3432d6e615
commit
85008303f5
7 changed files with 59 additions and 3 deletions
20
src/models/entities/used-username.ts
Normal file
20
src/models/entities/used-username.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { PrimaryColumn, Entity, Column } from 'typeorm';
|
||||
|
||||
@Entity()
|
||||
export class UsedUsername {
|
||||
@PrimaryColumn('varchar', {
|
||||
length: 128,
|
||||
})
|
||||
public username: string;
|
||||
|
||||
@Column('timestamp with time zone')
|
||||
public createdAt: Date;
|
||||
|
||||
constructor(data: Partial<UsedUsername>) {
|
||||
if (data == null) return;
|
||||
|
||||
for (const [k, v] of Object.entries(data)) {
|
||||
(this as any)[k] = v;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,6 +43,7 @@ import { HashtagRepository } from './repositories/hashtag';
|
|||
import { PageRepository } from './repositories/page';
|
||||
import { PageLikeRepository } from './repositories/page-like';
|
||||
import { ModerationLogRepository } from './repositories/moderation-logs';
|
||||
import { UsedUsername } from './entities/used-username';
|
||||
|
||||
export const Apps = getCustomRepository(AppRepository);
|
||||
export const Notes = getCustomRepository(NoteRepository);
|
||||
|
@ -64,6 +65,7 @@ export const UserGroups = getCustomRepository(UserGroupRepository);
|
|||
export const UserGroupJoinings = getRepository(UserGroupJoining);
|
||||
export const UserGroupInvites = getCustomRepository(UserGroupInviteRepository);
|
||||
export const UserNotePinings = getRepository(UserNotePining);
|
||||
export const UsedUsernames = getRepository(UsedUsername);
|
||||
export const Followings = getCustomRepository(FollowingRepository);
|
||||
export const FollowRequests = getCustomRepository(FollowRequestRepository);
|
||||
export const Instances = getRepository(Instance);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue