alias Pleroma.Web.AdminAPI.ReportView
alias Pleroma.Web.AdminAPI.Search
alias Pleroma.Web.CommonAPI
+ alias Pleroma.Web.Endpoint
alias Pleroma.Web.MastodonAPI.StatusView
+ alias Pleroma.Web.Router
import Pleroma.Web.ControllerHelper, only: [json_response: 3]
def get_password_reset(conn, %{"nickname" => nickname}) do
(%User{local: true} = user) = User.get_cached_by_nickname(nickname)
{:ok, token} = Pleroma.PasswordResetToken.create_token(user)
- host = Pleroma.Config.get([Pleroma.Web.Endpoint, :url, :host])
- protocol = Pleroma.Config.get([Pleroma.Web.Endpoint, :protocol])
conn
|> json(%{
token: token.token,
- link: "#{protocol}://#{host}/api/pleroma/password_reset/#{token.token}"
+ link: Router.Helpers.reset_password_url(Endpoint, :reset, token.token)
})
end
|> put_req_header("accept", "application/json")
|> get("/api/pleroma/admin/users/#{user.nickname}/password_reset")
- assert conn.status == 200
+ resp = json_response(conn, 200)
+
+ assert Regex.match?(~r/(http:\/\/|https:\/\/)/, resp["link"])
end
describe "GET /api/pleroma/admin/users" do