diff options
author | Simponic <loganhunt@simponic.xyz> | 2022-12-30 05:46:35 -0700 |
---|---|---|
committer | Simponic <loganhunt@simponic.xyz> | 2022-12-30 05:46:35 -0700 |
commit | 42425b02260d279cd9c12fb3e625282979b9e308 (patch) | |
tree | 0412bf9f39d44266cff94082c499e44e5f6e60f5 /lib/chessh/auth/keys.ex | |
parent | 60eea1b4ed65bc7cfce1e383dac6de9d004540eb (diff) | |
download | chessh-42425b02260d279cd9c12fb3e625282979b9e308.tar.gz chessh-42425b02260d279cd9c12fb3e625282979b9e308.zip |
Add scalable session thresholds
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, |