Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why did I have to create /views/googe_auth_new + templates/google_auth/welcome ? #63

Closed
ndrean opened this issue Sep 13, 2022 · 4 comments
Labels
question Further information is requested starter user-feedback

Comments

@ndrean
Copy link
Contributor

ndrean commented Sep 13, 2022

Tried to follow the guide but I had to create the files above. Did I do something wrong as you don't seem to need this.

@ndrean ndrean changed the title Why did I have to create /views/googe_auth_new + templates/welcome ? Why did I have to create /views/googe_auth_new + templates/google_auth/welcome ? Sep 13, 2022
@nelsonic nelsonic added question Further information is requested user-feedback starter labels Sep 13, 2022
@nelsonic
Copy link
Member

@ndrean dis you follow the example: https://github.com/dwyl/elixir-auth-google-demo ? 🤞

@ndrean
Copy link
Contributor Author

ndrean commented Sep 13, 2022

nope ....!   |> put_view(LiveMapWeb.PageView) ok!...
but do you need to go and inspect the example/demo? I mean, your page should be enough, shoudln't it?

also (5.1) <a href="<%= @oauth_google_url %>"> confused me, Instead <a href={@oauth_google_url} >

Little details you cannot invent.

@nelsonic
Copy link
Member

yes, the page is enough.
as for the "old" style of writing embedded Elixir (.eex),
you're right the (newer) curly brace syntax is simpler. 👍

@ndrean
Copy link
Contributor Author

ndrean commented Sep 14, 2022

So I understand that if you don't use put_view, then you need to define "/views/google_auth_view.ex" and "/templates/google_auth/welcome.html.heex". If you use put_view, then you can reference directly "/templates/page/welcome.html.heex". Since you did not create a specific view, you need to add the following:

  1. Create a GoogleAuthController in your Project
defmodule AppWeb.GoogleAuthController do
  use AppWeb, :controller
  def index(conn, %{"code" => code}) do
    {:ok, token} = ElixirAuthGoogle.get_token(code, conn)
    {:ok, profile} = ElixirAuthGoogle.get_user_profile(token.access_token)
    conn
     |> put_view(AppWeb.PageView)       <---------
     |> render(:welcome, profile: profile)
  end
end

6.1 Update the page/index.html.heex Template. <----- "heex"

<section class="phx-hero">
  <h1>Welcome to Awesome App!</h1>
  <p>To get started, login to your Google Account: <p>
  <a href={@oauth_google_url} >                                           <----------------------
    <img src="https://i.imgur.com/Kagbzkq.png" alt="Sign in with Google" />
  </a>
</section>

@ndrean ndrean closed this as completed Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested starter user-feedback
Projects
None yet
Development

No branches or pull requests

2 participants