Allow tag relations + bump ecto deps

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-02-14 14:19:55 +01:00
parent 4caa998ae0
commit 256d50e855
37 changed files with 515 additions and 132 deletions

View File

@@ -579,7 +579,7 @@ defmodule Mobilizon.Actors do
"""
def authenticate(%{user: user, password: password}) do
# Does password match the one stored in the database?
case Comeonin.Argon2.checkpw(password, user.password_hash) do
case Argon2.verify_pass(password, user.password_hash) do
true ->
# Yes, create and return the token
MobilizonWeb.Guardian.encode_and_sign(user)

View File

@@ -12,7 +12,7 @@ defmodule Mobilizon.Actors.Service.Activation do
with %User{} = user <- Actors.get_user_by_activation_token(token),
{:ok, %User{} = user} <-
Actors.update_user(user, %{
"confirmed_at" => DateTime.utc_now(),
"confirmed_at" => DateTime.utc_now() |> DateTime.truncate(:second),
"confirmation_sent_at" => nil,
"confirmation_token" => nil
}) do
@@ -26,7 +26,10 @@ defmodule Mobilizon.Actors.Service.Activation do
def resend_confirmation_email(%User{} = user, locale \\ "en") do
with :ok <- Tools.we_can_send_email(user, :confirmation_sent_at),
{:ok, user} <- Actors.update_user(user, %{"confirmation_sent_at" => DateTime.utc_now()}) do
{:ok, user} <-
Actors.update_user(user, %{
"confirmation_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second)
}) do
send_confirmation_email(user, locale)
Logger.info("Sent confirmation email again to #{user.email}")
{:ok, user.email}

View File

@@ -43,7 +43,7 @@ defmodule Mobilizon.Actors.Service.ResetPassword do
Repo.update(
User.send_password_reset_changeset(user, %{
"reset_password_token" => Tools.random_string(30),
"reset_password_sent_at" => DateTime.utc_now()
"reset_password_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second)
})
) do
mail =

View File

@@ -11,7 +11,10 @@ defmodule Mobilizon.Actors.Service.Tools do
:ok
_ ->
case Timex.before?(Timex.shift(Map.get(user, key), hours: 1), DateTime.utc_now()) do
case Timex.before?(
Timex.shift(Map.get(user, key), hours: 1),
DateTime.utc_now() |> DateTime.truncate(:second)
) do
true ->
:ok

View File

@@ -89,7 +89,12 @@ defmodule Mobilizon.Actors.User do
case changeset do
%Ecto.Changeset{valid?: true, changes: %{email: _email}} ->
changeset = put_change(changeset, :confirmation_token, random_string(30))
put_change(changeset, :confirmation_sent_at, DateTime.utc_now())
put_change(
changeset,
:confirmation_sent_at,
DateTime.utc_now() |> DateTime.truncate(:second)
)
_ ->
changeset
@@ -122,7 +127,7 @@ defmodule Mobilizon.Actors.User do
put_change(
changeset,
:password_hash,
Comeonin.Argon2.hashpwsalt(password)
Argon2.hash_pwd_salt(password)
)
_ ->