From 42425b02260d279cd9c12fb3e625282979b9e308 Mon Sep 17 00:00:00 2001 From: Simponic Date: Fri, 30 Dec 2022 05:46:35 -0700 Subject: Add scalable session thresholds --- lib/chessh/auth/password.ex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/chessh/auth/password.ex') 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 -- cgit v1.2.3-70-g09d2 From e7d8c61487815bd90ec5834dad5e6f64dd951b53 Mon Sep 17 00:00:00 2001 From: Simponic Date: Fri, 30 Dec 2022 05:51:47 -0700 Subject: More warning squashing --- lib/chessh/auth/password.ex | 1 - lib/chessh/ssh/cli.ex | 2 +- lib/chessh/ssh/daemon.ex | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) (limited to 'lib/chessh/auth/password.ex') diff --git a/lib/chessh/auth/password.ex b/lib/chessh/auth/password.ex index a01291d..0986169 100644 --- a/lib/chessh/auth/password.ex +++ b/lib/chessh/auth/password.ex @@ -8,7 +8,6 @@ defmodule Chessh.Auth.PasswordAuthenticator do def authenticate(username, password) do case Repo.get_by(Player, username: username) do player -> authenticate(player, password) - nil -> false end end end diff --git a/lib/chessh/ssh/cli.ex b/lib/chessh/ssh/cli.ex index c7befe0..71d789b 100644 --- a/lib/chessh/ssh/cli.ex +++ b/lib/chessh/ssh/cli.ex @@ -1,7 +1,7 @@ defmodule Chessh.SSH.Cli do @behaviour :ssh_server_channel - def init() do + def init(_args) do {:ok, %{}} end diff --git a/lib/chessh/ssh/daemon.ex b/lib/chessh/ssh/daemon.ex index 9ffc538..b341833 100644 --- a/lib/chessh/ssh/daemon.ex +++ b/lib/chessh/ssh/daemon.ex @@ -1,5 +1,5 @@ defmodule Chessh.SSH.Daemon do - alias Chessh.{Repo, PlayerSession, Player, Utils} + alias Chessh.{Repo, PlayerSession, Utils} alias Chessh.Auth.PasswordAuthenticator use GenServer import Ecto.Query -- cgit v1.2.3-70-g09d2