aboutsummaryrefslogtreecommitdiff
path: root/shardweb/lib/shard_web/controllers
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2018-09-26 15:59:22 +0200
committerAlex Auvolat <alex@adnab.me>2018-09-26 15:59:22 +0200
commit1a13285971ef728109011a93e676e26248b30242 (patch)
treef03467bc07ff84961f8c3eb88497adaf36b5f009 /shardweb/lib/shard_web/controllers
parent7d0009d83c9b5c747d4adb535817924762429f30 (diff)
downloadshard-1a13285971ef728109011a93e676e26248b30242.tar.gz
shard-1a13285971ef728109011a93e676e26248b30242.zip
Fixes
Diffstat (limited to 'shardweb/lib/shard_web/controllers')
-rw-r--r--shardweb/lib/shard_web/controllers/room_controller.ex10
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,