mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 13:17:24 +01:00
add length and character limitations for login name (username) (#9895)
* update API comments to for `username` restrictions and to use Login Name terminology We use "login name" rather than "username" in user-visible text on the website and (usually) when communicating with users because "username" could be confused with "profile name". Using it in the docs allows you to search for that term. * add alphanumeric and length validation for creating new login name (username) The 'en-US' locale is specified explicitly to ensure we never use another locale. The point of this change is to limit the character set to prevent login names being used to send spam in the Welcome emails, such as Chinese language spam we've had trouble with. * add error messages for bad login names * allow login name to also contain hyphens This is because our automated tests generate user accounts using: let username = generateUUID(); * allow login names to be up to 36 characters long because we use UUIDs as login names in our tests * revert back to using max 20 characters and only a-z, 0-9 for login name. It's been decided to change the username generation in the tests instead. * disable test that is failing because it's redundant Spaces are now prohibited by other code. We can probably delete this test later. I don't want to delete it now, but instead give us time to think about that. * fix typos * revert to login name restrictions that allow us to keep using our existing test code I'm really not comfortable changing our test suite in ways that aren't essential, especially since we're working in a hurry with a larger chance than normal of breaking things. The 36 character length is larger than we initially decided but not so much larger that it's a huge problem. We can reduce it to 20 when we have more time. * limit username length to 20 chars * fix tests
This commit is contained in:
@@ -6,10 +6,14 @@ import {
|
||||
getProperty,
|
||||
} from '../../../../../helpers/api-integration/v3';
|
||||
import { ApiUser } from '../../../../../helpers/api-integration/api-classes';
|
||||
import { v4 as generateRandomUserName } from 'uuid';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { each } from 'lodash';
|
||||
import { encrypt } from '../../../../../../website/server/libs/encryption';
|
||||
|
||||
function generateRandomUserName () {
|
||||
return (Date.now() + uuid()).substring(0, 20);
|
||||
}
|
||||
|
||||
describe('POST /user/auth/local/register', () => {
|
||||
context('username and email are free', () => {
|
||||
let api;
|
||||
@@ -37,7 +41,8 @@ describe('POST /user/auth/local/register', () => {
|
||||
expect(user.newUser).to.eql(true);
|
||||
});
|
||||
|
||||
it('remove spaces from username', async () => {
|
||||
xit('remove spaces from username', async () => {
|
||||
// TODO can probably delete this test now
|
||||
let username = ' usernamewithspaces ';
|
||||
let email = 'test@example.com';
|
||||
let password = 'password';
|
||||
|
||||
Reference in New Issue
Block a user