From faffe24c5ce2be1051e4658029e59fd7d53e88ac Mon Sep 17 00:00:00 2001 From: SimonLab Date: Wed, 13 May 2020 15:11:38 +0100 Subject: [PATCH] use Map.merge instead of Map.put, https://github.com/dwyl/auth/pull/43#discussion_r424017852 --- lib/auth/person.ex | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/auth/person.ex b/lib/auth/person.ex index f59e7f0f..3f667345 100644 --- a/lib/auth/person.ex +++ b/lib/auth/person.ex @@ -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) @@ -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 @@ -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