Skip to content

Commit

Permalink
use Map.merge instead of Map.put, #43 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonLab committed May 13, 2020
1 parent 326b524 commit faffe24
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions lib/auth/person.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,11 @@ defmodule Auth.Person do
end

def create_person(person) do
# IO.inspect(person, label: "create_person:51")
person =
%Person{}
|> changeset(person)
|> put_email_status_verified()

# |> IO.inspect(label: "after put_email_status_verified")

case get_person_by_email(person.changes.email) do
nil ->
Repo.insert!(person)
Expand Down Expand Up @@ -103,11 +100,12 @@ defmodule Auth.Person do
}
"""
def transform_github_profile_data_to_person(profile) do
profile
|> Map.put(:username, profile.login)
|> Map.put(:givenName, profile.name)
|> Map.put(:picture, profile.avatar_url)
|> Map.put(:auth_provider, "github")
Map.merge(profile, %{
username: profile.login,
givenName: profile.name,
picture: profile.avatar_url,
auth_provider: "github"
})
end

def create_github_person(profile) do
Expand Down Expand Up @@ -146,14 +144,11 @@ defmodule Auth.Person do
}
"""
def transform_google_profile_data_to_person(profile) do
# IO.inspect(profile, label: "profile:145")
Map.merge(profile, %{
familyName: profile.family_name,
givenName: profile.given_name,
auth_provider: "google"
})

# |> IO.inspect(label: "merged")
end

def create_google_person(profile) do
Expand Down

0 comments on commit faffe24

Please sign in to comment.