From b4743f9efb685545cdd780cc9ba7a50e083dd8cf Mon Sep 17 00:00:00 2001 From: Simponic Date: Mon, 19 Dec 2022 02:39:40 -0700 Subject: Get public key authenticator actually running, add password validator via hash --- lib/chessh/auth/password.ex | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lib/chessh/auth/password.ex (limited to 'lib/chessh/auth/password.ex') diff --git a/lib/chessh/auth/password.ex b/lib/chessh/auth/password.ex new file mode 100644 index 0000000..a6fa73d --- /dev/null +++ b/lib/chessh/auth/password.ex @@ -0,0 +1,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 -- cgit v1.2.3-70-g09d2