Skip to content

Commit

Permalink
access person data with ., #29
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonLab committed Dec 4, 2019
1 parent 6e68240 commit 96198e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/app_web/controllers/google_auth_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule AppWeb.GoogleAuthController do
person = App.Ctx.Person.transform_profile_data_to_person(profile)

# get the person by email
case App.Ctx.get_person_by_email(profile["email"]) do
case App.Ctx.get_person_by_email(person["email"]) do
nil ->
# Create the person
{:ok, google_person} = App.Ctx.create_google_person(person)
Expand All @@ -25,15 +25,15 @@ defmodule AppWeb.GoogleAuthController do

# Create Phoenix session
AppWeb.Auth.login(conn, google_person)
|> render("index.html", person: person)
|> render("index.html", person: google_person)

person ->
# create new session and
session_attrs = %{
"auth_token" => token["access_token"],
"refresh_token" => "dummy_refresh_token", # we don't need refresh for now.
}
App.Ctx.create_session(person, session_attrs)

# Create Phoenix session
AppWeb.Auth.login(conn, person)
|> render("index.html", person: person)
Expand Down
8 changes: 3 additions & 5 deletions lib/app_web/templates/google_auth/index.html.eex
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@


<a class="cf right-0 top-0" width="40px" href="<%= Routes.page_path(@conn, :index) %>">
<img class="br-100 fl " width="32px" src="<%= @person["picture"] %>" />
<img class="br-100 fl " width="32px" src="<%= @person.picture %>" />
</a>

<section>
<h1 class="tc mid-grey"> Hello <%= @person["givenName"] %>!</h1>
<h1 class="tc mid-grey"> Hello <%= @person.givenName %>!</h1>
<p class="tc f4">
You are <strong>signed in</strong>
with your <strong>Google Account</strong>
<span class="dwyl-teal">
<%= @person["email"] %>
<%= @person.email %>
</span>
<p/>
</section>
Expand Down

0 comments on commit 96198e9

Please sign in to comment.