Prevent username reusing
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import $ from 'cafy';
|
||||
import define from '../../define';
|
||||
import { Users } from '../../../../models';
|
||||
import { Users, UsedUsernames } from '../../../../models';
|
||||
|
||||
export const meta = {
|
||||
tags: ['users'],
|
||||
@ -21,7 +21,9 @@ export default define(meta, async (ps) => {
|
||||
usernameLower: ps.username.toLowerCase()
|
||||
});
|
||||
|
||||
const exist2 = await UsedUsernames.count({ username: ps.username.toLowerCase() });
|
||||
|
||||
return {
|
||||
available: exist === 0
|
||||
available: exist === 0 && exist2 === 0
|
||||
};
|
||||
});
|
||||
|
Reference in New Issue
Block a user