diff --git a/lib/auth_web/controllers/app_controller.ex b/lib/auth_web/controllers/app_controller.ex index 74ab0b90..140c9dd2 100644 --- a/lib/auth_web/controllers/app_controller.ex +++ b/lib/auth_web/controllers/app_controller.ex @@ -119,7 +119,6 @@ defmodule AuthWeb.AppController do end end - # @doc """ # approles/2 Return the (JSON) List of Roles for a given App based on apikey.client_id # """ diff --git a/lib/auth_web/controllers/auth_controller.ex b/lib/auth_web/controllers/auth_controller.ex index 42a757ec..f2e0332f 100644 --- a/lib/auth_web/controllers/auth_controller.ex +++ b/lib/auth_web/controllers/auth_controller.ex @@ -176,6 +176,8 @@ defmodule AuthWeb.AuthController do # display welcome page on Auth site: false -> + # Grant app_admin role to person who authenticated directly on auth app + # Auth.PeopleRoles.insert(1, person.id, 8) conn |> AuthPlug.create_jwt_session(person) |> render(:welcome, person: person) diff --git a/priv/repo/default_roles.json b/priv/repo/default_roles.json index 96ba103d..ba2e29c9 100644 --- a/priv/repo/default_roles.json +++ b/priv/repo/default_roles.json @@ -53,6 +53,6 @@ "desc": "Can manage their own App(s).", "person_id": "1", "id": "8", - "permissions": "manage_apps, create_content, upload_images, edit_own_content, delete_own_content, invite_people" + "permissions": "manage_own_apps, create_content, upload_images, edit_own_content, delete_own_content, invite_people" } ] \ No newline at end of file diff --git a/test/auth_web/controllers/auth_controller_test.exs b/test/auth_web/controllers/auth_controller_test.exs index 08b7906d..a6fbd0b8 100644 --- a/test/auth_web/controllers/auth_controller_test.exs +++ b/test/auth_web/controllers/auth_controller_test.exs @@ -91,6 +91,16 @@ defmodule AuthWeb.AuthControllerTest do end end + # test "redirect_or_render assigns app_admin role if direct auth", %{conn: conn} do + # conn = non_admin_login(conn) + # IO.inspect(conn, label: "conn:96") + # person = conn.assigns.person + # IO.inspect(person, label: "person:98") + + # AuthWeb.AuthController.redirect_or_render(conn, person, "") + # IO.inspect(conn, label: "conn:100") + # end + test "github_handler/2 github auth callback", %{conn: conn} do baseurl = AuthPlug.Helpers.get_baseurl_from_conn(conn) diff --git a/test/auth_web/controllers/role_controller_test.exs b/test/auth_web/controllers/role_controller_test.exs index d116409e..a9149e32 100644 --- a/test/auth_web/controllers/role_controller_test.exs +++ b/test/auth_web/controllers/role_controller_test.exs @@ -42,13 +42,16 @@ defmodule AuthWeb.RoleControllerTest do test "non-admin person create role", %{conn: conn} do conn = non_admin_login(conn) - {:ok, _app} = Auth.App.create_app(%{ - "name" => "default system app", - "desc" => "Demo App", - "url" => "localhost:4000", - "person_id" => conn.assigns.person.id, - "status" => 3 - }) + + {:ok, _app} = + Auth.App.create_app(%{ + "name" => "default system app", + "desc" => "Demo App", + "url" => "localhost:4000", + "person_id" => conn.assigns.person.id, + "status" => 3 + }) + conn = get(conn, Routes.role_path(conn, :new)) assert html_response(conn, 200) =~ "New Role" end diff --git a/test/test_helper.exs b/test/test_helper.exs index 5dc978a9..b4942153 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -23,9 +23,11 @@ defmodule AuthTest do end def non_admin_person() do - rand = :rand.uniform(1000000) + rand = :rand.uniform(1_000_000) + Auth.Person.upsert_person(%{ email: "alex+#{rand}@gmail.com", + givenName: "Alexander McAwesome", auth_provider: "email", password: "thiswillbehashed" })