Skip to content

Commit

Permalink
fix: Ensure usernames are lowercase; allow case-insensitive user search
Browse files Browse the repository at this point in the history
  • Loading branch information
baumandm committed Dec 22, 2021
1 parent 5780350 commit 415156f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/backend/src/resolvers/user.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class UserResolver {
@Query(() => User, { nullable: true })
async user(@Arg('userName') userName: string, @Ctx() ctx: Context): Promise<User | null> {
try {
const user = await User.query().where('userName', userName).first();
const user = await User.query().where('userName', userName.toLowerCase()).first();

// Store this for authorization checks later
ctx.retrievedUserId = user?.userId;
Expand Down Expand Up @@ -116,7 +116,7 @@ export class UserResolver {

// Preferred username is email, but that's not a great user name
// Default to the first part of their email
const userName = userInfo.preferred_username.split('@')[0];
const userName = userInfo.preferred_username.split('@')[0].toLowerCase();

// Upsert feature pending: https://github.com/knex/knex/pull/3763
await User.knex().raw(
Expand Down

0 comments on commit 415156f

Please sign in to comment.