Created
March 14, 2016 07:50
-
-
Save nguyenvinhlinh/bc69a3913e545da4a66b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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