First
[anni] / lib / pleroma / bbs / authenticator.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.BBS.Authenticator do
6   use Sshd.PasswordAuthenticator
7   alias Pleroma.User
8   alias Pleroma.Web.Plugs.AuthenticationPlug
9
10   def authenticate(username, password) do
11     username = to_string(username)
12     password = to_string(password)
13
14     with %User{} = user <- User.get_by_nickname(username) do
15       AuthenticationPlug.checkpw(password, user.password_hash)
16     else
17       _e -> false
18     end
19   end
20 end