mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
fixes #11047 Switches Hall query to use lowercase name
This commit is contained in:
@@ -54,7 +54,7 @@ describe('GET /heroes/:heroId', () => {
|
|||||||
expect(heroRes.profile).to.have.all.keys(['name']);
|
expect(heroRes.profile).to.have.all.keys(['name']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns only necessary hero data given username', async () => {
|
it('returns only necessary hero data given username with display case', async () => {
|
||||||
let hero = await generateUser({
|
let hero = await generateUser({
|
||||||
contributor: {tier: 23},
|
contributor: {tier: 23},
|
||||||
});
|
});
|
||||||
@@ -67,4 +67,16 @@ describe('GET /heroes/:heroId', () => {
|
|||||||
expect(heroRes.auth.local).not.to.have.keys(['salt', 'hashed_password']);
|
expect(heroRes.auth.local).not.to.have.keys(['salt', 'hashed_password']);
|
||||||
expect(heroRes.profile).to.have.all.keys(['name']);
|
expect(heroRes.profile).to.have.all.keys(['name']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns hero data given username without case sensitivity', async () => {
|
||||||
|
let hero = await generateUser({}, 'TestUpperCaseName123');
|
||||||
|
let heroRes = await user.get(`/hall/heroes/${hero.auth.local.username.toLowerCase()}`);
|
||||||
|
|
||||||
|
expect(heroRes).to.have.all.keys([
|
||||||
|
'_id', 'id', 'balance', 'profile', 'purchased',
|
||||||
|
'contributor', 'auth', 'items',
|
||||||
|
]);
|
||||||
|
expect(heroRes.auth.local).not.to.have.keys(['salt', 'hashed_password']);
|
||||||
|
expect(heroRes.profile).to.have.all.keys(['name']);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import * as Tasks from '../../../../website/server/models/task';
|
|||||||
// parameter, such as the number of wolf eggs the user has,
|
// parameter, such as the number of wolf eggs the user has,
|
||||||
// , you can do so by passing in the full path as a string:
|
// , you can do so by passing in the full path as a string:
|
||||||
// { 'items.eggs.Wolf': 10 }
|
// { 'items.eggs.Wolf': 10 }
|
||||||
export async function generateUser (update = {}) {
|
export async function generateUser (update = {}, manualUsername = null) {
|
||||||
let username = (Date.now() + generateUUID()).substring(0, 20);
|
let username = manualUsername || (Date.now() + generateUUID()).substring(0, 20);
|
||||||
let password = 'password';
|
let password = 'password';
|
||||||
let email = `${username}@example.com`;
|
let email = `${username}@example.com`;
|
||||||
|
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ api.getHero = {
|
|||||||
if (validator.isUUID(heroId)) {
|
if (validator.isUUID(heroId)) {
|
||||||
query = {_id: heroId};
|
query = {_id: heroId};
|
||||||
} else {
|
} else {
|
||||||
query = {'auth.local.username': heroId};
|
query = {'auth.local.lowerCaseUsername': heroId.toLowerCase()};
|
||||||
}
|
}
|
||||||
|
|
||||||
const hero = await User
|
const hero = await User
|
||||||
|
|||||||
Reference in New Issue
Block a user