diff options
Diffstat (limited to 'shardweb/lib/shard_web/controllers/room_controller.ex')
-rw-r--r-- | shardweb/lib/shard_web/controllers/room_controller.ex | 10 |
1 files changed, 6 insertions, 4 deletions
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, |