Skip to content

Commit

Permalink
Make user lookup by username case-insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
ku1ik committed Aug 25, 2023
1 parent 2d893fc commit e947c9e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/asciinema/accounts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,14 @@ defmodule Asciinema.Accounts do
if String.contains?(identifier, "@") do
{:email, Repo.get_by(User, email: identifier)}
else
{:username, Repo.get_by(User, username: identifier)}
user =
Repo.one(
from(u in User,
where: fragment("lower(?)", u.username) == ^String.downcase(identifier)
)
)

{:username, user}
end
end

Expand Down

0 comments on commit e947c9e

Please sign in to comment.