diff options
Diffstat (limited to 'lib/chessh/auth/keys.ex')
-rw-r--r-- | lib/chessh/auth/keys.ex | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/chessh/auth/keys.ex b/lib/chessh/auth/keys.ex index a29d169..f0e1c78 100644 --- a/lib/chessh/auth/keys.ex +++ b/lib/chessh/auth/keys.ex @@ -1,7 +1,16 @@ defmodule Chessh.Auth.KeyAuthenticator do - alias Chessh.{Key, Repo} + alias Chessh.{Key, Repo, Player} import Ecto.Query + def authenticate(player = %Player{}, public_key) do + !!Repo.one( + from(k in Key, + where: k.key == ^Key.encode_key(public_key), + where: k.player_id == ^player.id + ) + ) + end + def authenticate(username, public_key) do !!Repo.one( from(k in Key, |