From 36f87d48d322b5a4de605eadcf2a5ccf450d4ad3 Mon Sep 17 00:00:00 2001 From: nelsonic Date: Sun, 26 Apr 2020 13:24:14 +0100 Subject: [PATCH] render DWYL_API_KEY from client_id and client_secret #42 --- lib/auth_web/controllers/apikey_controller.ex | 8 ++------ lib/auth_web/templates/apikey/show.html.eex | 11 +++++------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/auth_web/controllers/apikey_controller.ex b/lib/auth_web/controllers/apikey_controller.ex index 10027e20..cc5af3e5 100644 --- a/lib/auth_web/controllers/apikey_controller.ex +++ b/lib/auth_web/controllers/apikey_controller.ex @@ -33,14 +33,10 @@ defmodule AuthWeb.ApikeyController do def create(conn, %{"apikey" => apikey_params}) do IO.inspect(apikey_params, label: "apikey_params") person_id = conn.assigns.decoded.id - secret = Fields.AES.encrypt(person_id) |> Base58.encode - |> IO.inspect(label: "secret") - client = Fields.AES.encrypt(person_id) |> Base58.encode - |> IO.inspect(label: "client") params = Map.merge(apikey_params, %{ - "client_secret" => secret, - "client_id" => client, + "client_secret" => encrypt_encode(person_id), + "client_id" => encrypt_encode(person_id), "person_id" => person_id }) case Apikey.create_apikey(params) do diff --git a/lib/auth_web/templates/apikey/show.html.eex b/lib/auth_web/templates/apikey/show.html.eex index e85b4622..6f5c0ecd 100644 --- a/lib/auth_web/templates/apikey/show.html.eex +++ b/lib/auth_web/templates/apikey/show.html.eex @@ -1,17 +1,16 @@ -

Show Apikey

+

Your DWYL_API_KEY

- DWYL_API_KEY: -

- <%= @apikey.client_id %><%= @apikey.client_secret %> + <%= @apikey.client_id %>/<%= @apikey.client_secret %>

- Name: + Key Name: <%= @apikey.name %>

@@ -21,7 +20,7 @@

- Url: + URL: <%= @apikey.url %>