From 1a13285971ef728109011a93e676e26248b30242 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 26 Sep 2018 15:59:22 +0200 Subject: Fixes --- shardweb/lib/shard_web/controllers/room_controller.ex | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'shardweb/lib/shard_web/controllers') diff --git a/shardweb/lib/shard_web/controllers/room_controller.ex b/shardweb/lib/shard_web/controllers/room_controller.ex index 48ba2a4..8c98aa6 100644 --- a/shardweb/lib/shard_web/controllers/room_controller.ex +++ b/shardweb/lib/shard_web/controllers/room_controller.ex @@ -5,18 +5,20 @@ defmodule ShardWeb.RoomController do import PhoenixGon.Controller def show(conn, %{"room" => room}) do - {pk, conn} = case get_session(conn, :pk) do - nil -> + pk = get_session(conn, :pk) + {pk, conn} = cond do + pk == nil || not Shard.Keys.have_sk? pk -> pk = Shard.Keys.get_any_identity conn = put_session(conn, :pk, pk) {pk, conn} - x -> - {x, conn} + true -> + {pk, conn} end name = SApp.Identity.get_nick pk conn = put_gon(conn, chat_room: room) + conn = put_gon(conn, pk: (pk|>Base.encode16)) render conn, "show.html", room: room, pk: pk, -- cgit v1.2.3