Skip to content

Instantly share code, notes, and snippets.

@motephyr
Created September 12, 2017 04:59
Show Gist options
  • Select an option

  • Save motephyr/8b56bc136d9d6015cf3eab1be3903a40 to your computer and use it in GitHub Desktop.

Select an option

Save motephyr/8b56bc136d9d6015cf3eab1be3903a40 to your computer and use it in GitHub Desktop.
def password_match(conn, _) do
owner = Coherence.current_user(conn)
house = conn.assigns[:house]
password = conn.params["house_bid"]["password"]
result = Config.user_schema.checkpw(password, Map.get(owner, Config.password_hash))
if result do
conn
else
conn
|> put_flash(:error, "密碼不正確")
|> redirect(to: house_path(conn, :show, house))
|> halt
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment