Skip to content

Commit

Permalink
add auth_url to api key and display on app show page, #162
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonLab committed Nov 15, 2021
1 parent 165571d commit e37565e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/auth_web/controllers/app_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ defmodule AuthWeb.AppController do
use AuthWeb, :controller
alias Auth.App

@auth_url "https://dwylauth.herokuapp.com"

def index(conn, _params) do
render(conn, "index.html", apps: Auth.App.list_apps(conn))
end
Expand All @@ -12,7 +14,6 @@ defmodule AuthWeb.AppController do
end

def create(conn, %{"app" => app_params}) do
# IO.inspect(app_params, label: "app_params:16")
attrs =
Map.merge(app_params, %{
"person_id" => conn.assigns.person.id,
Expand All @@ -21,7 +22,6 @@ defmodule AuthWeb.AppController do

case App.create_app(attrs) do
{:ok, app} ->
# IO.inspect(app, label: "app:23")
conn
|> put_flash(:info, "App created successfully.")
|> redirect(to: Routes.app_path(conn, :show, app))
Expand All @@ -35,7 +35,7 @@ defmodule AuthWeb.AppController do
app = App.get_app!(id)
#  restrict viewership to owner||admin https://github.com/dwyl/auth/issues/99
if conn.assigns.person.id == app.person_id || conn.assigns.person.id == 1 do
render(conn, "show.html", app: app)
render(conn, "show.html", app: app, auth_url: @auth_url)
else
AuthWeb.AuthController.not_found(conn, "this page does not exist")
end
Expand Down Expand Up @@ -107,7 +107,7 @@ defmodule AuthWeb.AppController do
# get the app again and render it:
conn
|> put_flash(:info, "Your API Key has been successfully reset")
|> render("show.html", app: App.get_app!(id))
|> render("show.html", app: App.get_app!(id), auth_url: @auth_url)
end
end
end
4 changes: 2 additions & 2 deletions lib/auth_web/templates/app/show.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
<div style="font-size: 1.2em;
overflow-wrap: break-word; font-family: monospace;
border: 1px solid black; padding: 10px; background-color: #EBEDEF;">
<%= apikey.client_id %>/<%= apikey.client_secret %>
<%= apikey.client_id %>/<%= apikey.client_secret %>-<%= @auth_url %>
</div>
</p>

<p> Export it as an environment variable:
<div style="font-size: 1.2em;
overflow-wrap: break-word; font-family: monospace;
border: 1px solid black; padding: 10px; background-color: #EBEDEF;">
export AUTH_API_KEY=<%= apikey.client_id %>/<%= apikey.client_secret %>
export AUTH_API_KEY=<%= apikey.client_id %>/<%= apikey.client_secret %>-<%= @auth_url %>
</div>
</p>
<% end %>
Expand Down

0 comments on commit e37565e

Please sign in to comment.