From 3cdd44ca55ffd15d4617df8f98f25eb0ab688e20 Mon Sep 17 00:00:00 2001 From: nelsonic Date: Tue, 28 Apr 2020 15:32:38 +0100 Subject: [PATCH] create_apikey_for_admin/1 in seeds.exs for #55 --- priv/repo/seeds.exs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/priv/repo/seeds.exs b/priv/repo/seeds.exs index db099e9a..6699a59a 100644 --- a/priv/repo/seeds.exs +++ b/priv/repo/seeds.exs @@ -31,7 +31,25 @@ defmodule Auth.Seeds do IO.inspect(person.id, label: "seeds.exs person.id") IO.puts("- - - - - - - - - - - - - - - - - - - - - - ") + + person + end + + def create_apikey_for_admin(person) do + + {:ok, key} = %{"name" => "default key", "url" => "http://localhost:4000"} + |> AuthWeb.ApikeyController.make_apikey(person.id) + # |> IO.inspect(label: "apikey_params") + |> Auth.Apikey.create_apikey() + + # IO.inspect(key, label: "key") + api_key = key.client_id <> "/" <> key.client_secret + # Set the AUTH_API_KEY to a valid value that is in the DB: + System.put_env("AUTH_API_KEY", api_key) + IO.inspect(System.get_env("AUTH_API_KEY"), label: "AUTH_API_KEY") + key end end Auth.Seeds.create_admin() +|> Auth.Seeds.create_apikey_for_admin()