Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
trenpixster committed Apr 7, 2016
1 parent ef3c965 commit 113f39d
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 21 deletions.
12 changes: 0 additions & 12 deletions lib/addict/crypto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,4 @@ Signs and verifies text
defp do_verify(false) do
{:error, [{:token, "Password reset token not valid."}]}
end

defp decode_key(key) do
Base.decode64(key) |> do_decode_key
end

defp do_decode_key(:error) do
{:error, ["Addict secret_key", "Addict.Configs.secret_key is invalid"]}
end

defp do_decode_key(key) do
key
end
end
6 changes: 3 additions & 3 deletions lib/addict/interactors/validate_password.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ defmodule Addict.Interactors.ValidatePassword do
call(changeset, [])
end

def call(changeset, strategies \\ []) do
def call(changeset, strategies) do
if Enum.count(strategies) == 0, do: strategies = [:default]

messages = strategies
strategies
|> Enum.reduce(changeset, fn (strategy, acc) ->
validate(strategy, acc)
end)
Expand All @@ -33,7 +33,7 @@ defmodule Addict.Interactors.ValidatePassword do
end

defp validate(:default, changeset) do
Ecto.Changeset.validate_change(changeset, :password, fn (field, value) ->
Ecto.Changeset.validate_change(changeset, :password, fn (_field, value) ->
validate(:default, value)
end).errors
end
Expand Down
2 changes: 1 addition & 1 deletion lib/addict/interactors/validate_user_for_registration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ defmodule Addict.PasswordUser do
end
end

defmodule Addict.Interactors.ValidateUserForRegistration do
@doc """
Validates if the user is valid for insertion.
Checks if `password` is valid and if `email` is well formatted and unique.
Returns `{:ok, []}` or `{:error, [errors]}`
"""
defmodule Addict.Interactors.ValidateUserForRegistration do
import Ecto.Changeset
alias Addict.Interactors.ValidatePassword
def call(user_params, configs \\ Addict.Configs) do
Expand Down
2 changes: 0 additions & 2 deletions lib/addict/interactors/verify_password.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
defmodule Addict.Interactors.VerifyPassword do
import Ecto.Query

@doc """
Verifies if the password for the user is valid
Expand Down
2 changes: 1 addition & 1 deletion lib/addict/mailers/generic.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Addict.Mailers.Generic do
@moduledoc """
Defines the required behaviour for e-mail providers
"""
defmodule Addict.Mailers.Generic do
@callback send_email(String.t, String.t, String.t, String.t) :: any
end
4 changes: 2 additions & 2 deletions lib/addict/mailers/mail_sender.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule Addict.Mailers.MailSender do
user = user_params |> convert_to_list
html_body = EEx.eval_string(template, user)
from_email = Addict.Configs.from_email || "no-reply@addict.github.io"
Addict.Mailers.send_email(user_params["email"], Addict.Configs.from_email, subject, html_body)
Addict.Mailers.send_email(user_params["email"], from_email, subject, html_body)
end

def send_reset_token(email, path, host \\ Addict.Configs.host) do
Expand All @@ -20,7 +20,7 @@ defmodule Addict.Mailers.MailSender do
params = %{"email" => email, "path" => path} |> convert_to_list
html_body = EEx.eval_string(template, params)
from_email = Addict.Configs.from_email || "no-reply@addict.github.io"
Addict.Mailers.send_email(email, Addict.Configs.from_email, subject, html_body)
Addict.Mailers.send_email(email, from_email, subject, html_body)
end

defp convert_to_list(params) do
Expand Down

0 comments on commit 113f39d

Please sign in to comment.