diff options
Diffstat (limited to 'lib/chessh/auth/password.ex')
-rw-r--r-- | lib/chessh/auth/password.ex | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/chessh/auth/password.ex b/lib/chessh/auth/password.ex index ea2c8fc..a01291d 100644 --- a/lib/chessh/auth/password.ex +++ b/lib/chessh/auth/password.ex @@ -1,9 +1,14 @@ defmodule Chessh.Auth.PasswordAuthenticator do alias Chessh.{Player, Repo} + def authenticate(player = %Player{}, password) do + Player.valid_password?(player, password) + end + def authenticate(username, password) do case Repo.get_by(Player, username: username) do - x -> Player.valid_password?(x, password) + player -> authenticate(player, password) + nil -> false end end end |