Skip to content

Commit 375df50

Browse files
committed
refactor: simplify code
1 parent 83f3f82 commit 375df50

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/algora/accounts/accounts.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,15 @@ defmodule Algora.Accounts do
286286
Registers a user from their GitHub information.
287287
"""
288288
def register_github_user(current_user, primary_email, info, emails, token) do
289-
query =
290-
from(u in User,
291-
where: u.email == ^primary_email or (u.provider == "github" and u.provider_id == ^to_string(info["id"]))
289+
matching_users =
290+
Repo.all(
291+
from u in User,
292+
where: u.email == ^primary_email or (u.provider == "github" and u.provider_id == ^to_string(info["id"]))
292293
)
293294

294295
primary_user =
295-
case {current_user, Repo.all(query)} do
296+
case {current_user, matching_users} do
296297
{current_user, _} when not is_nil(current_user) -> current_user
297-
{_, []} -> nil
298298
{_, [user]} -> user
299299
{_, users} -> Enum.find(users, &(&1.provider == "github" and &1.provider_id == to_string(info["id"])))
300300
end

0 commit comments

Comments
 (0)