summaryrefslogtreecommitdiff
path: root/lib/chessh/auth/password.ex
blob: a6fa73d3632de1f6fef510c30af686663acb58d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
defmodule Chessh.Auth.PasswordAuthenticator do
  alias Chessh.Player
  alias Chessh.Repo
  use Sshd.PasswordAuthenticator

  def authenticate(username, password) do
    case Repo.get_by(Player, username: String.Chars.to_string(username)) do
      nil -> false
      x -> Player.valid_password?(x, password)
    end
  end
end