/crm.ex Secret
Last active
July 8, 2017 06:52
Revisions
-
shankardevy revised this gist
Jul 8, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ defmodule Mango.CRM do customer && Comeonin.Bcrypt.checkpw(pass, customer.password_hash) -> customer true -> :error end end end -
shankardevy created this gist
Jul 8, 2017 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ defmodule Mango.CRM do alias Mango.Repo alias Mango.CRM.Customer def build_customer(attrs \\ %{}) do %Customer{} |> Customer.changeset(attrs) end def create_customer(attrs) do attrs |> build_customer |> Repo.insert end def get_customer_by_email(email), do: Repo.get_by(Customer, email: email) def get_customer_by_credentials(%{"email" => email, "password" => pass} ) do customer = get_customer_by_email(email) cond do customer && Comeonin.Bcrypt.checkpw(pass, customer.password_hash) -> customer true -> {:error} end end end