[#923] Merge remote-tracking branch 'remotes/upstream/develop' into twitter_oauth
# Conflicts: # config/config.exs # lib/pleroma/web/auth/pleroma_authenticator.ex
This commit is contained in:
commit
2a96283efb
35 changed files with 733 additions and 38 deletions
|
|
@ -8,9 +8,16 @@ defmodule Pleroma.Web.Auth.PleromaAuthenticator do
|
|||
|
||||
@behaviour Pleroma.Web.Auth.Authenticator
|
||||
|
||||
def get_user(%Plug.Conn{} = _conn, %{
|
||||
"authorization" => %{"name" => name, "password" => password}
|
||||
}) do
|
||||
def get_user(%Plug.Conn{} = _conn, params) do
|
||||
{name, password} =
|
||||
case 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
|
||||
{:ok, user}
|
||||
|
|
@ -20,8 +27,6 @@ defmodule Pleroma.Web.Auth.PleromaAuthenticator do
|
|||
end
|
||||
end
|
||||
|
||||
def get_user(%Plug.Conn{} = _conn, _params), do: {:error, :missing_credentials}
|
||||
|
||||
def get_or_create_user_by_oauth(
|
||||
%Plug.Conn{assigns: %{ueberauth_auth: %{provider: provider, uid: uid} = auth}},
|
||||
_params
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue