add tests for deactivated users for mongoose auth
This commit is contained in:
parent
a626cb682c
commit
5c7cc10917
@ -28,7 +28,12 @@ defmodule Pleroma.Web.MongooseIM.MongooseIMController do
|
|||||||
def check_password(conn, %{"user" => username, "pass" => password}) do
|
def check_password(conn, %{"user" => username, "pass" => password}) do
|
||||||
user = Repo.get_by(User, nickname: username, local: true)
|
user = Repo.get_by(User, nickname: username, local: true)
|
||||||
|
|
||||||
case User.account_status(user) do
|
state = case user do
|
||||||
|
nil -> nil
|
||||||
|
_ -> User.account_status(user)
|
||||||
|
end
|
||||||
|
|
||||||
|
case state do
|
||||||
:deactivated ->
|
:deactivated ->
|
||||||
conn
|
conn
|
||||||
|> put_status(:not_found)
|
|> put_status(:not_found)
|
||||||
|
@ -34,6 +34,7 @@ defmodule Pleroma.Web.MongooseIMController do
|
|||||||
|
|
||||||
test "/check_password", %{conn: conn} do
|
test "/check_password", %{conn: conn} do
|
||||||
user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt("cool"))
|
user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt("cool"))
|
||||||
|
_deactivated_user = insert(:user, nickname: "konata", local: false, deactivated: true)
|
||||||
|
|
||||||
res =
|
res =
|
||||||
conn
|
conn
|
||||||
@ -51,6 +52,14 @@ defmodule Pleroma.Web.MongooseIMController do
|
|||||||
|
|
||||||
res =
|
res =
|
||||||
conn
|
conn
|
||||||
|
|> get(mongoose_im_path(conn, :check_password), user: "konata", pass: "1337")
|
||||||
|
|> json_response(404)
|
||||||
|
|
||||||
|
assert res == false
|
||||||
|
|
||||||
|
|
||||||
|
res =
|
||||||
|
conn
|
||||||
|> get(mongoose_im_path(conn, :check_password), user: "nobody", pass: "cool")
|
|> get(mongoose_im_path(conn, :check_password), user: "nobody", pass: "cool")
|
||||||
|> json_response(404)
|
|> json_response(404)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user