Merge remote-tracking branch 'origin/main'

nix run .#update

added cacerts_load check to build inside Nix sandbox
This commit is contained in:
778a69cd 2023-08-19 13:59:48 +02:00
commit 8d9ddbdfe8
22 changed files with 103 additions and 58 deletions

View file

@ -113,17 +113,24 @@ config :mobilizon, :media_proxy,
config :mobilizon, Mobilizon.Web.Email.Mailer, config :mobilizon, Mobilizon.Web.Email.Mailer,
adapter: Swoosh.Adapters.SMTP, adapter: Swoosh.Adapters.SMTP,
relay: "localhost", relay: "localhost",
# usually 25, 465 or 587
port: 25,
username: "", username: "",
password: "", password: "",
# can be `:always` or `:never` # can be `:always` or `:never`
auth: :if_available, auth: :if_available,
# can be `true` # can be `true`
ssl: false, # ssl: false,
# can be `:always` or `:never` # can be `:always` or `:never`
tls: :if_available, tls: :if_available,
allowed_tls_versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"], allowed_tls_versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"],
tls_options: [
verify: :verify_peer,
versions: [:"tlsv1.2", :"tlsv1.3"],
cacerts: if :public_key.cacerts_load(System.get_env("SSL_CERT_FILE")) == :ok do
:public_key.cacerts_get()
end,
server_name_indication: "localhost",
depth: 99
],
retries: 1, retries: 1,
# can be `true` # can be `true`
no_mx_lookups: false no_mx_lookups: false

View file

@ -50,7 +50,14 @@ config :mobilizon, Mobilizon.Web.Email.Mailer,
username: System.get_env("MOBILIZON_SMTP_USERNAME", nil), username: System.get_env("MOBILIZON_SMTP_USERNAME", nil),
password: System.get_env("MOBILIZON_SMTP_PASSWORD", nil), password: System.get_env("MOBILIZON_SMTP_PASSWORD", nil),
tls: :if_available, tls: :if_available,
allowed_tls_versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"], allowed_tls_versions: [:"tlsv1.2", :"tlsv1.3"],
tls_options: [
verify: :verify_peer,
versions: [:"tlsv1.2", :"tlsv1.3"],
cacerts: :public_key.cacerts_get(),
server_name_indication: System.get_env("MOBILIZON_SMTP_SERVER", "localhost"),
depth: 99
],
ssl: System.get_env("MOBILIZON_SMTP_SSL", "false"), ssl: System.get_env("MOBILIZON_SMTP_SSL", "false"),
retries: 1, retries: 1,
no_mx_lookups: false, no_mx_lookups: false,

View file

@ -24,7 +24,7 @@
</div> </div>
<ErrorComponent v-if="error" :error="error" /> <ErrorComponent v-if="error" :error="error" />
<main id="main" class="pt-4" v-else> <main id="main" class="px-2 py-4" v-else>
<router-view></router-view> <router-view></router-view>
</main> </main>
<mobilizon-footer /> <mobilizon-footer />

View file

@ -55,7 +55,7 @@ body {
} }
.btn-outlined-:hover, .btn-outlined-:hover,
.btn-outlined-primary:hover { .btn-outlined-primary:hover {
@apply font-bold py-2 px-4 bg-mbz-bluegreen dark:bg-violet-3 text-white rounded; @apply font-semibold py-2 px-4 bg-mbz-bluegreen dark:bg-violet-3 text-white rounded;
} }
/* Field */ /* Field */
@ -89,7 +89,7 @@ body {
/* Input */ /* Input */
.input { .input {
@apply appearance-none box-border border w-full py-2 px-3 text-black leading-tight dark:bg-zinc-600 dark:placeholder:text-zinc-400 dark:text-zinc-50; @apply appearance-none box-border rounded border w-full py-2 px-3 text-black leading-tight dark:bg-zinc-600 dark:placeholder:text-zinc-400 dark:text-zinc-50;
} }
.input-danger { .input-danger {
@apply border-red-500; @apply border-red-500;

View file

@ -14,8 +14,8 @@
@confirm-leave="confirmLeave" @confirm-leave="confirmLeave"
@cancel-anonymous-participation="cancelAnonymousParticipation" @cancel-anonymous-participation="cancelAnonymousParticipation"
/> />
<div class="flex flex-col"> <div class="flex flex-col gap-1 mt-1">
<p class="inline-flex gap-1"> <p class="inline-flex gap-2 ml-auto">
<TicketConfirmationOutline /> <TicketConfirmationOutline />
<router-link <router-link
class="participations-link" class="participations-link"
@ -92,7 +92,7 @@
</template> </template>
</VTooltip> </VTooltip>
</p> </p>
<o-dropdown> <o-dropdown class="ml-auto">
<template #trigger> <template #trigger>
<o-button icon-right="dots-horizontal"> <o-button icon-right="dots-horizontal">
{{ t("Actions") }} {{ t("Actions") }}

View file

@ -13,6 +13,7 @@
</template> </template>
<o-button <o-button
v-if="canShowLocateMeButton" v-if="canShowLocateMeButton"
class="!h-auto"
ref="mapMarker" ref="mapMarker"
icon-right="map-marker" icon-right="map-marker"
@click="locateMe" @click="locateMe"
@ -63,7 +64,7 @@
<o-button <o-button
:disabled="!queryTextWithDefault" :disabled="!queryTextWithDefault"
@click="resetAddress" @click="resetAddress"
class="reset-area" class="reset-area !h-auto"
icon-left="close" icon-left="close"
:title="t('Clear address field')" :title="t('Clear address field')"
/> />

View file

@ -1,5 +1,5 @@
<template> <template>
<div> <div class="ml-auto w-min">
<o-dropdown <o-dropdown
v-if="participation && participation.role === ParticipantRole.PARTICIPANT" v-if="participation && participation.role === ParticipantRole.PARTICIPANT"
> >

View file

@ -25,6 +25,7 @@ export const orugaConfig = {
}, },
inputitems: { inputitems: {
itemClass: "inputitems-item", itemClass: "inputitems-item",
containerClass: "rounded",
}, },
autocomplete: { autocomplete: {
menuClass: "autocomplete-menu", menuClass: "autocomplete-menu",

View file

@ -49,6 +49,7 @@ export class Dialog {
hasInput, hasInput,
}, },
autoFocus: false, autoFocus: false,
contentClass: "!w-11/12",
}); });
} }
@ -87,6 +88,7 @@ export class Dialog {
onConfirm, onConfirm,
onCancel, onCancel,
}, },
contentClass: "!w-11/12",
}); });
} }
} }

View file

@ -53,7 +53,7 @@
/> />
<p class="control"> <p class="control">
<span class="button is-static">@{{ getInstanceHost }}</span> <span class="button is-static !h-auto">@{{ getInstanceHost }}</span>
</p> </p>
</o-field> </o-field>
</o-field> </o-field>

View file

@ -1,5 +1,5 @@
<template> <template>
<div class="container mx-auto px-1" v-if="hasCurrentActorPermissionsToEdit"> <div class="container mx-auto" v-if="hasCurrentActorPermissionsToEdit">
<h1 class="" v-if="isUpdate === true"> <h1 class="" v-if="isUpdate === true">
{{ t("Update event {name}", { name: event.title }) }} {{ t("Update event {name}", { name: event.title }) }}
</h1> </h1>
@ -473,7 +473,7 @@
<nav <nav
role="navigation" role="navigation"
aria-label="main navigation" aria-label="main navigation"
class="bg-mbz-yellow-alt-200 py-3" class="bg-mbz-yellow-alt-200 p-3 mt-3 rounded"
:class="{ 'is-fixed-bottom': showFixedNavbar }" :class="{ 'is-fixed-bottom': showFixedNavbar }"
v-if="hasCurrentActorPermissionsToEdit" v-if="hasCurrentActorPermissionsToEdit"
> >
@ -482,11 +482,11 @@
<span class="dark:text-gray-900" v-if="isEventModified"> <span class="dark:text-gray-900" v-if="isEventModified">
{{ t("Unsaved changes") }} {{ t("Unsaved changes") }}
</span> </span>
<div class="flex flex-wrap gap-3 items-center"> <div class="flex flex-wrap gap-3 items-center justify-end">
<o-button <o-button
variant="text" variant="text"
@click="confirmGoBack" @click="confirmGoBack"
class="dark:!text-black" class="dark:!text-black ml-auto"
>{{ t("Cancel") }}</o-button >{{ t("Cancel") }}</o-button
> >
<!-- If an event has been published we can't make it draft anymore --> <!-- If an event has been published we can't make it draft anymore -->
@ -500,7 +500,7 @@
>{{ t("Save draft") }}</o-button >{{ t("Save draft") }}</o-button
> >
</span> </span>
<span class=""> <span class="ml-auto">
<o-button <o-button
variant="primary" variant="primary"
:disabled="saving" :disabled="saving"

View file

@ -4,7 +4,7 @@
<div class="flex flex-col mb-3"> <div class="flex flex-col mb-3">
<event-banner :picture="event?.picture" /> <event-banner :picture="event?.picture" />
<div <div
class="flex flex-col relative pb-2 bg-white dark:bg-zinc-700 my-2 rounded" class="flex flex-col relative pb-2 bg-white dark:bg-zinc-700 my-4 rounded"
> >
<div class="date-calendar-icon-wrapper relative" v-if="event?.beginsOn"> <div class="date-calendar-icon-wrapper relative" v-if="event?.beginsOn">
<skeleton-date-calendar-icon <skeleton-date-calendar-icon
@ -26,7 +26,7 @@
</div> </div>
<section class="intro px-2 pt-4" dir="auto"> <section class="intro px-2 pt-4" dir="auto">
<div class="flex flex-wrap gap-2"> <div class="flex flex-wrap gap-2 justify-end">
<div class="flex-1 min-w-[300px]"> <div class="flex-1 min-w-[300px]">
<div <div
v-if="eventLoading" v-if="eventLoading"

View file

@ -67,7 +67,7 @@
/> />
<o-button <o-button
@click="dateFilter = new Date()" @click="dateFilter = new Date()"
class="reset-area" class="reset-area !h-auto"
icon-left="close" icon-left="close"
:title="t('Clear date filter field')" :title="t('Clear date filter field')"
/> />

View file

@ -302,6 +302,9 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
{:error, :invalid_email} -> {:error, :invalid_email} ->
{:error, dgettext("errors", "This email doesn't seem to be valid")} {:error, dgettext("errors", "This email doesn't seem to be valid")}
{:error, :failed_sending_mail} ->
{:error, dgettext("errors", "Couldn't send an email. Internal error.")}
{:error, :email_too_soon} -> {:error, :email_too_soon} ->
{:error, {:error,
dgettext( dgettext(

View file

@ -4,10 +4,18 @@ defmodule Mobilizon.Web.Email.Mailer do
""" """
use Swoosh.Mailer, otp_app: :mobilizon use Swoosh.Mailer, otp_app: :mobilizon
alias Mobilizon.Service.ErrorReporting.Sentry alias Mobilizon.Service.ErrorReporting.Sentry
require Logger
@spec send_email(Swoosh.Email.t()) :: {:ok, term} | {:error, term} @spec send_email(Swoosh.Email.t()) :: {:ok, term} | {:error, term}
def send_email(email) do def send_email(email) do
Mobilizon.Web.Email.Mailer.deliver(email) Logger.debug(
"Mailer options #{inspect(Keyword.drop(Application.get_env(:mobilizon, Mobilizon.Web.Email.Mailer), [:tls_options]))}"
)
Logger.debug("Sending mail, #{inspect(email)}")
res = Mobilizon.Web.Email.Mailer.deliver(email)
Logger.debug("Return from sending mail #{inspect(res)}")
res
rescue rescue
error -> error ->
Sentry.capture_exception(error, Sentry.capture_exception(error,

View file

@ -91,13 +91,19 @@ defmodule Mobilizon.Web.Email.User do
Users.update_user(user, %{ Users.update_user(user, %{
"confirmation_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second) "confirmation_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second)
}) do }) do
send_confirmation_email(user, locale) case send_confirmation_email(user, locale) do
{:ok, _} ->
Logger.info("Sent confirmation email again to #{user.email}") Logger.info("Sent confirmation email again to #{user.email}")
{:ok, user.email} {:ok, user.email}
{:error, err} ->
Logger.error("Failed sending email to #{user.email}. #{inspect(err)}")
{:error, :failed_sending_mail}
end
end end
end end
@spec send_confirmation_email(User.t(), String.t()) :: Swoosh.Email.t() @spec send_confirmation_email(User.t(), String.t()) :: {:ok, term} | {:error, term}
def send_confirmation_email(%User{} = user, locale \\ "en") do def send_confirmation_email(%User{} = user, locale \\ "en") do
user user
|> Email.User.confirmation_email(locale) |> Email.User.confirmation_email(locale)

View file

@ -211,7 +211,7 @@ defmodule Mobilizon.Mixfile do
{:nimble_csv, "~> 1.1"}, {:nimble_csv, "~> 1.1"},
{:export, "~> 0.1.0"}, {:export, "~> 0.1.0"},
{:erlport, "~> 0.11.0"}, {:erlport, "~> 0.11.0"},
{:tz_world, "~> 1.0"}, {:tz_world, "1.3.0"},
{:tzdata, "~> 1.1"}, {:tzdata, "~> 1.1"},
{:codepagex, "~> 0.1.6"}, {:codepagex, "~> 0.1.6"},
{:vite_phx, "~> 0.2"}, {:vite_phx, "~> 0.2"},

View file

@ -139,7 +139,7 @@
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"}, "telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
"tesla": {:hex, :tesla, "1.7.0", "a62dda2f80d4f8a925eb7b8c5b78c461e0eb996672719fe1a63b26321a5f8b4e", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: true]}, {:finch, "~> 0.13", [hex: :finch, repo: "hexpm", optional: true]}, {:fuse, "~> 2.4", [hex: :fuse, repo: "hexpm", optional: true]}, {:gun, "~> 1.3", [hex: :gun, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: true]}, {:ibrowse, "4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:msgpax, "~> 2.3", [hex: :msgpax, repo: "hexpm", optional: true]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "2e64f01ebfdb026209b47bc651a0e65203fcff4ae79c11efb73c4852b00dc313"}, "tesla": {:hex, :tesla, "1.7.0", "a62dda2f80d4f8a925eb7b8c5b78c461e0eb996672719fe1a63b26321a5f8b4e", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: true]}, {:finch, "~> 0.13", [hex: :finch, repo: "hexpm", optional: true]}, {:fuse, "~> 2.4", [hex: :fuse, repo: "hexpm", optional: true]}, {:gun, "~> 1.3", [hex: :gun, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: true]}, {:ibrowse, "4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:msgpax, "~> 2.3", [hex: :msgpax, repo: "hexpm", optional: true]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "2e64f01ebfdb026209b47bc651a0e65203fcff4ae79c11efb73c4852b00dc313"},
"timex": {:hex, :timex, "3.7.11", "bb95cb4eb1d06e27346325de506bcc6c30f9c6dea40d1ebe390b262fad1862d1", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.20", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 1.1", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm", "8b9024f7efbabaf9bd7aa04f65cf8dcd7c9818ca5737677c7b76acbc6a94d1aa"}, "timex": {:hex, :timex, "3.7.11", "bb95cb4eb1d06e27346325de506bcc6c30f9c6dea40d1ebe390b262fad1862d1", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.20", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 1.1", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm", "8b9024f7efbabaf9bd7aa04f65cf8dcd7c9818ca5737677c7b76acbc6a94d1aa"},
"tz_world": {:hex, :tz_world, "1.3.1", "dedb8373fce594098909ff36d37f5e5e30e47cb40ef846d1dfc91eb39f7ebaaf", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:geo, "~> 1.0 or ~> 2.0 or ~> 3.3", [hex: :geo, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "901ed2b4a4430ecab3765244da4a19e6f19141867c2ab3753924919b87ed2224"}, "tz_world": {:hex, :tz_world, "1.3.0", "a4d70486c7934b710f8b3b4374d62ebdd75e3d2b8914771ef6c62c3635a6088f", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:geo, "~> 1.0 or ~> 2.0 or ~> 3.3", [hex: :geo, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "78b565aa0899b48ce34686319119dfdadff07a255ec43fd9ed6e7d60cc8d1390"},
"tzdata": {:hex, :tzdata, "1.1.1", "20c8043476dfda8504952d00adac41c6eda23912278add38edc140ae0c5bcc46", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "a69cec8352eafcd2e198dea28a34113b60fdc6cb57eb5ad65c10292a6ba89787"}, "tzdata": {:hex, :tzdata, "1.1.1", "20c8043476dfda8504952d00adac41c6eda23912278add38edc140ae0c5bcc46", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "a69cec8352eafcd2e198dea28a34113b60fdc6cb57eb5ad65c10292a6ba89787"},
"ueberauth": {:hex, :ueberauth, "0.10.5", "806adb703df87e55b5615cf365e809f84c20c68aa8c08ff8a416a5a6644c4b02", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "3efd1f31d490a125c7ed453b926f7c31d78b97b8a854c755f5c40064bf3ac9e1"}, "ueberauth": {:hex, :ueberauth, "0.10.5", "806adb703df87e55b5615cf365e809f84c20c68aa8c08ff8a416a5a6644c4b02", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "3efd1f31d490a125c7ed453b926f7c31d78b97b8a854c755f5c40064bf3ac9e1"},
"ueberauth_cas": {:hex, :ueberauth_cas, "2.3.1", "df45a1f2c5df8bc80191cbca4baeeed808d697702ec5ebe5bd5d5a264481752f", [:mix], [{:httpoison, "~> 1.8", [hex: :httpoison, repo: "hexpm", optional: false]}, {:sweet_xml, "~> 0.7", [hex: :sweet_xml, repo: "hexpm", optional: false]}, {:ueberauth, "~> 0.6", [hex: :ueberauth, repo: "hexpm", optional: false]}], "hexpm", "5068ae2b9e217c2f05aa9a67483a6531e21ba0be9a6f6c8749bb7fd1599be321"}, "ueberauth_cas": {:hex, :ueberauth_cas, "2.3.1", "df45a1f2c5df8bc80191cbca4baeeed808d697702ec5ebe5bd5d5a264481752f", [:mix], [{:httpoison, "~> 1.8", [hex: :httpoison, repo: "hexpm", optional: false]}, {:sweet_xml, "~> 0.7", [hex: :sweet_xml, repo: "hexpm", optional: false]}, {:ueberauth, "~> 0.6", [hex: :ueberauth, repo: "hexpm", optional: false]}], "hexpm", "5068ae2b9e217c2f05aa9a67483a6531e21ba0be9a6f6c8749bb7fd1599be321"},

View file

@ -1791,12 +1791,12 @@ let
tz_world = buildMix rec { tz_world = buildMix rec {
name = "tz_world"; name = "tz_world";
version = "1.3.1"; version = "1.3.0";
src = fetchHex { src = fetchHex {
pkg = "${name}"; pkg = "${name}";
version = "${version}"; version = "${version}";
sha256 = "0912xn3rp49475sv6akwhr0r3wg6355dli2jfsrwl3j3ljsd47lh"; sha256 = "140kip660zbfxpckzi2y4mxg1pysvwcr2cc68viqrd4r12m6bdbq";
}; };
beamDeps = [ castore certifi geo jason ]; beamDeps = [ castore certifi geo jason ];

View file

@ -75,6 +75,13 @@ server {
default_type "text/plain"; default_type "text/plain";
} }
location ~ ^/img {
root /opt/mobilizon/priv/static;
etag off;
access_log off;
add_header Cache-Control "public, max-age=31536000, immutable";
}
location ~ ^/(js|css) { location ~ ^/(js|css) {
root /opt/mobilizon/priv/static; root /opt/mobilizon/priv/static;
etag off; etag off;

View file

@ -75,6 +75,13 @@ server {
default_type "text/plain"; default_type "text/plain";
} }
location ~ ^/img {
root /opt/mobilizon/priv/static;
etag off;
access_log off;
add_header Cache-Control "public, max-age=31536000, immutable";
}
location ~ ^/(js|css) { location ~ ^/(js|css) {
root /home/mobilizon/live/priv/static; root /home/mobilizon/live/priv/static;
etag off; etag off;

View file

@ -121,6 +121,12 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do
} }
""" """
@resend_registration_email_mutation """
mutation ResendConfirmationEmail($email: String!) {
resendConfirmationEmail(email: $email)
}
"""
@send_reset_password_mutation """ @send_reset_password_mutation """
mutation SendResetPassword($email: String!) { mutation SendResetPassword($email: String!) {
sendResetPassword(email: $email) sendResetPassword(email: $email)
@ -706,22 +712,16 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do
describe "Resolver: Resend confirmation emails" do describe "Resolver: Resend confirmation emails" do
test "test resend_confirmation_email/3 with valid email resends an validation email", test "test resend_confirmation_email/3 with valid email resends an validation email",
context do %{conn: conn} do
{:ok, %User{} = user} = Users.register(%{email: "toto@tata.tld", password: "p4ssw0rd"}) {:ok, %User{} = user} = Users.register(%{email: "toto@tata.tld", password: "p4ssw0rd"})
mutation = """
mutation {
resendConfirmationEmail(
email: "#{user.email}"
)
}
"""
res = res =
context.conn AbsintheHelpers.graphql_query(conn,
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation)) query: @resend_registration_email_mutation,
variables: %{email: user.email}
)
assert hd(json_response(res, 200)["errors"])["message"] == assert hd(res["errors"])["message"] ==
"You requested again a confirmation email too soon. Please try again in a few minutes" "You requested again a confirmation email too soon. Please try again in a few minutes"
# Hammer time ! # Hammer time !
@ -730,28 +730,24 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do
}) })
res = res =
context.conn AbsintheHelpers.graphql_query(conn,
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation)) query: @resend_registration_email_mutation,
variables: %{email: user.email}
)
assert json_response(res, 200)["data"]["resendConfirmationEmail"] == user.email assert res["data"]["resendConfirmationEmail"] == user.email
assert_email_sent(to: user.email) assert_email_sent(to: user.email)
end end
test "test resend_confirmation_email/3 with invalid email resends an validation email", test "test resend_confirmation_email/3 with invalid email does not resend an validation email",
context do %{conn: conn} do
mutation = """
mutation {
resendConfirmationEmail(
email: "oh@no.com"
)
}
"""
res = res =
context.conn AbsintheHelpers.graphql_query(conn,
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation)) query: @resend_registration_email_mutation,
variables: %{email: "oh@no.com"}
)
assert hd(json_response(res, 200)["errors"])["message"] == assert hd(res["errors"])["message"] ==
"No user to validate with this email was found" "No user to validate with this email was found"
end end
end end