From 01328d183e72dd3c7483d9c4fc43a2998035c96e Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 11 Jul 2018 13:46:19 +0200 Subject: [PATCH] Add some identities UI Signed-off-by: Thomas Citharel --- js/src/App.vue | 65 +++++---- js/src/components/Account/Identities.vue | 132 ++++++++++++++++++ js/src/main.js | 2 +- js/src/router/index.js | 7 + .../controllers/actor_controller.ex | 9 ++ 5 files changed, 186 insertions(+), 29 deletions(-) create mode 100644 js/src/components/Account/Identities.vue diff --git a/js/src/App.vue b/js/src/App.vue index d3c2b8fec..70cb7fd6f 100644 --- a/js/src/App.vue +++ b/js/src/App.vue @@ -10,37 +10,46 @@ > - - - - - + value="false" + > + + + + + - - {{ this.displayed_name }} - - + + {{ this.displayed_name }} + + - - - - + + + + - - Autre identité - - + + Autre identité + + + + + + group + + + Identities + + + + diff --git a/js/src/main.js b/js/src/main.js index 0db22d7c9..d7f3406ea 100644 --- a/js/src/main.js +++ b/js/src/main.js @@ -38,7 +38,7 @@ Vue.i18n.set(language); Vue.i18n.fallback('en'); router.beforeEach((to, from, next) => { - if (to.matched.some(record => record.meta.requiredAuth)) { + if (to.matched.some(record => record.meta.requiredAuth) && !store.state.user) { next({ name: 'Login', query: { redirect: to.fullPath }, diff --git a/js/src/router/index.js b/js/src/router/index.js index 48579a1f2..7b1f82f92 100644 --- a/js/src/router/index.js +++ b/js/src/router/index.js @@ -18,6 +18,7 @@ import Account from '@/components/Account/Account'; import CreateGroup from '@/components/Group/Create'; import Group from '@/components/Group/Group'; import GroupList from '@/components/Group/GroupList'; +import Identities from '../components/Account/Identities.vue'; Vue.use(Router); @@ -110,6 +111,12 @@ const router = new Router({ props: true, meta: { requiredAuth: false }, }, + { + path: '/identities', + name: 'Identities', + component: Identities, + meta: { requiredAuth: true }, + }, { path: '/groups', name: 'GroupList', diff --git a/lib/eventos_web/controllers/actor_controller.ex b/lib/eventos_web/controllers/actor_controller.ex index 03dc14c3b..f55f1ba9b 100644 --- a/lib/eventos_web/controllers/actor_controller.ex +++ b/lib/eventos_web/controllers/actor_controller.ex @@ -18,6 +18,7 @@ defmodule EventosWeb.ActorController do def create(conn, %{"actor" => actor_params}) do with %User{} = user <- Guardian.Plug.current_resource(conn), actor_params <- Map.put(actor_params, "user_id", user.id), + actor_params <- Map.put(actor_params, "keys", keys_for_account()), {:ok, %Actor{} = actor} <- Actors.create_actor(actor_params) do conn |> put_status(:created) @@ -26,6 +27,14 @@ defmodule EventosWeb.ActorController do end end + defp keys_for_account() do + key = :public_key.generate_key({:rsa, 2048, 65_537}) + entry = :public_key.pem_entry_encode(:RSAPrivateKey, key) + [entry] + |> :public_key.pem_encode() + |> String.trim_trailing() + end + def show(conn, %{"name" => name}) do actor = Actors.get_actor_by_name_with_everything(name) render(conn, "show.json", actor: actor)