Move LDAP code to LDAPAuthenticator. Use Authenticator for token_exchange with grant_type as well
This commit is contained in:
parent
19e2b85247
commit
88a672fe88
4 changed files with 55 additions and 32 deletions
|
|
@ -9,7 +9,14 @@ defmodule Pleroma.Web.Auth.PleromaAuthenticator do
|
|||
@behaviour Pleroma.Web.Auth.Authenticator
|
||||
|
||||
def get_user(%Plug.Conn{} = conn) do
|
||||
%{"authorization" => %{"name" => name, "password" => password}} = conn.params
|
||||
{name, password} =
|
||||
case conn.params do
|
||||
%{"authorization" => %{"name" => name, "password" => password}} ->
|
||||
{name, password}
|
||||
|
||||
%{"grant_type" => "password", "username" => name, "password" => password} ->
|
||||
{name, password}
|
||||
end
|
||||
|
||||
with {_, %User{} = user} <- {:user, User.get_by_nickname_or_email(name)},
|
||||
{_, true} <- {:checkpw, Pbkdf2.checkpw(password, user.password_hash)} do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue