oauth: fix password-based login when username is email address
authorWilliam Pitcock <nenolod@dereferenced.org>
Thu, 14 Jun 2018 02:29:52 +0000 (02:29 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Thu, 14 Jun 2018 02:32:30 +0000 (02:32 +0000)
closes #199

lib/pleroma/web/oauth/oauth_controller.ex

index 3dd87d0ab9d7ea716ec7af8b32a59e2dc98d5e11..47962bbf868cff4bc8635bfcb1f5b67427c003b9 100644 (file)
@@ -84,7 +84,7 @@ defmodule Pleroma.Web.OAuth.OAuthController do
         %{"grant_type" => "password", "name" => name, "password" => password} = params
       ) do
     with %App{} = app <- get_app_from_request(conn, params),
-         %User{} = user <- User.get_cached_by_nickname(name),
+         %User{} = user <- User.get_by_nickname_or_email(name),
          true <- Pbkdf2.checkpw(password, user.password_hash),
          {:ok, auth} <- Authorization.create_authorization(app, user),
          {:ok, token} <- Token.exchange_token(app, auth) do