Skip to content

Instantly share code, notes, and snippets.

@nguyenvinhlinh
Created March 14, 2016 07:50
Show Gist options
  • Save nguyenvinhlinh/bc69a3913e545da4a66b to your computer and use it in GitHub Desktop.
Save nguyenvinhlinh/bc69a3913e545da4a66b to your computer and use it in GitHub Desktop.
def connect(%{"username" => username, "chat_token" => chat_token}, socket) do
case Repo.get_by(User, username: username) do
nil ->
:error
user ->
if user.chat_token == chat_token do
socket = assign(socket, :current_user, user)
{:ok, socket}
else
:error
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment