Compare commits
2 Commits
35de8a6395
...
1276635a3e
Author | SHA1 | Date | |
---|---|---|---|
1276635a3e | |||
f00dc50215 |
@ -29,33 +29,28 @@ defmodule Memex.Email do
|
|||||||
def generate_email("welcome", user, %{"url" => url}) do
|
def generate_email("welcome", user, %{"url" => url}) do
|
||||||
user
|
user
|
||||||
|> base_email(dgettext("emails", "confirm your memEx account"))
|
|> base_email(dgettext("emails", "confirm your memEx account"))
|
||||||
|> html_email(:confirm_email_html, %{user: user, url: url})
|
|> render_body(:confirm_email, %{user: user, url: url})
|
||||||
|> text_email(:confirm_email_text, %{user: user, url: url})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_email("reset_password", user, %{"url" => url}) do
|
def generate_email("reset_password", user, %{"url" => url}) do
|
||||||
user
|
user
|
||||||
|> base_email(dgettext("emails", "reset your memEx password"))
|
|> base_email(dgettext("emails", "reset your memEx password"))
|
||||||
|> html_email(:reset_password_html, %{user: user, url: url})
|
|> render_body(:reset_password, %{user: user, url: url})
|
||||||
|> text_email(:reset_password_text, %{user: user, url: url})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_email("update_email", user, %{"url" => url}) do
|
def generate_email("update_email", user, %{"url" => url}) do
|
||||||
user
|
user
|
||||||
|> base_email(dgettext("emails", "update your memEx email"))
|
|> base_email(dgettext("emails", "update your memEx email"))
|
||||||
|> html_email(:update_email_html, %{user: user, url: url})
|
|> render_body(:update_email, %{user: user, url: url})
|
||||||
|> text_email(:update_email_text, %{user: user, url: url})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
defp html_email(email, atom, assigns) do
|
defp render_body(email, template, assigns) do
|
||||||
heex = apply(EmailHTML, atom, [assigns])
|
html_heex = apply(EmailHTML, String.to_existing_atom("#{template}_html"), [assigns])
|
||||||
html = render_to_string(Layouts, "email_html", "html", email: email, inner_content: heex)
|
html = render_to_string(Layouts, "email_html", "html", email: email, inner_content: html_heex)
|
||||||
email |> html_body(html)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp text_email(email, atom, assigns) do
|
text_heex = apply(EmailHTML, String.to_existing_atom("#{template}_text"), [assigns])
|
||||||
heex = apply(EmailHTML, atom, [assigns])
|
text = render_to_string(Layouts, "email_text", "text", email: email, inner_content: text_heex)
|
||||||
text = render_to_string(Layouts, "email_text", "text", email: email, inner_content: heex)
|
|
||||||
email |> text_body(text)
|
email |> html_body(html) |> text_body(text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -22,8 +22,6 @@ defmodule MemexWeb.Router do
|
|||||||
plug :accepts, ["json"]
|
plug :accepts, ["json"]
|
||||||
end
|
end
|
||||||
|
|
||||||
## Authentication routes
|
|
||||||
|
|
||||||
scope "/", MemexWeb do
|
scope "/", MemexWeb do
|
||||||
pipe_through [:browser, :redirect_if_user_is_authenticated]
|
pipe_through [:browser, :redirect_if_user_is_authenticated]
|
||||||
|
|
||||||
@ -40,6 +38,12 @@ defmodule MemexWeb.Router do
|
|||||||
scope "/", MemexWeb do
|
scope "/", MemexWeb do
|
||||||
pipe_through [:browser, :require_authenticated_user]
|
pipe_through [:browser, :require_authenticated_user]
|
||||||
|
|
||||||
|
get "/users/settings", UserSettingsController, :edit
|
||||||
|
put "/users/settings", UserSettingsController, :update
|
||||||
|
delete "/users/settings/:id", UserSettingsController, :delete
|
||||||
|
get "/users/settings/confirm_email/:token", UserSettingsController, :confirm_email
|
||||||
|
get "/export/:mode", ExportController, :export
|
||||||
|
|
||||||
live_session :default, on_mount: [{MemexWeb.UserAuth, :ensure_authenticated}] do
|
live_session :default, on_mount: [{MemexWeb.UserAuth, :ensure_authenticated}] do
|
||||||
live "/notes/new", NoteLive.Index, :new
|
live "/notes/new", NoteLive.Index, :new
|
||||||
live "/notes/:slug/edit", NoteLive.Index, :edit
|
live "/notes/:slug/edit", NoteLive.Index, :edit
|
||||||
@ -55,17 +59,16 @@ defmodule MemexWeb.Router do
|
|||||||
live "/pipeline/:slug/add_step", PipelineLive.Show, :add_step
|
live "/pipeline/:slug/add_step", PipelineLive.Show, :add_step
|
||||||
live "/pipeline/:slug/:step_id", PipelineLive.Show, :edit_step
|
live "/pipeline/:slug/:step_id", PipelineLive.Show, :edit_step
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/users/settings", UserSettingsController, :edit
|
|
||||||
put "/users/settings", UserSettingsController, :update
|
|
||||||
delete "/users/settings/:id", UserSettingsController, :delete
|
|
||||||
get "/users/settings/confirm_email/:token", UserSettingsController, :confirm_email
|
|
||||||
get "/export/:mode", ExportController, :export
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/", MemexWeb do
|
scope "/", MemexWeb do
|
||||||
pipe_through [:browser]
|
pipe_through [:browser]
|
||||||
|
|
||||||
|
delete "/users/log_out", UserSessionController, :delete
|
||||||
|
get "/users/confirm", UserConfirmationController, :new
|
||||||
|
post "/users/confirm", UserConfirmationController, :create
|
||||||
|
get "/users/confirm/:token", UserConfirmationController, :confirm
|
||||||
|
|
||||||
live_session :public, on_mount: [{MemexWeb.UserAuth, :mount_current_user}] do
|
live_session :public, on_mount: [{MemexWeb.UserAuth, :mount_current_user}] do
|
||||||
live "/", HomeLive
|
live "/", HomeLive
|
||||||
live "/faq", FaqLive
|
live "/faq", FaqLive
|
||||||
@ -87,6 +90,8 @@ defmodule MemexWeb.Router do
|
|||||||
scope "/", MemexWeb do
|
scope "/", MemexWeb do
|
||||||
pipe_through [:browser, :require_authenticated_user, :require_admin]
|
pipe_through [:browser, :require_authenticated_user, :require_admin]
|
||||||
|
|
||||||
|
live_dashboard "/dashboard", metrics: MemexWeb.Telemetry, ecto_repos: [Memex.Repo]
|
||||||
|
|
||||||
live_session :admin, on_mount: [{MemexWeb.UserAuth, :ensure_admin}] do
|
live_session :admin, on_mount: [{MemexWeb.UserAuth, :ensure_admin}] do
|
||||||
live "/invites", InviteLive.Index, :index
|
live "/invites", InviteLive.Index, :index
|
||||||
live "/invites/new", InviteLive.Index, :new
|
live "/invites/new", InviteLive.Index, :new
|
||||||
@ -94,21 +99,6 @@ defmodule MemexWeb.Router do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/", MemexWeb do
|
|
||||||
pipe_through [:browser, :require_authenticated_user, :require_admin]
|
|
||||||
|
|
||||||
live_dashboard "/dashboard", metrics: MemexWeb.Telemetry, ecto_repos: [Memex.Repo]
|
|
||||||
end
|
|
||||||
|
|
||||||
scope "/", MemexWeb do
|
|
||||||
pipe_through [:browser]
|
|
||||||
|
|
||||||
delete "/users/log_out", UserSessionController, :delete
|
|
||||||
get "/users/confirm", UserConfirmationController, :new
|
|
||||||
post "/users/confirm", UserConfirmationController, :create
|
|
||||||
get "/users/confirm/:token", UserConfirmationController, :confirm
|
|
||||||
end
|
|
||||||
|
|
||||||
# Enables the Swoosh mailbox preview in development.
|
# Enables the Swoosh mailbox preview in development.
|
||||||
#
|
#
|
||||||
# Note that preview only shows emails that were sent by the same
|
# Note that preview only shows emails that were sent by the same
|
||||||
|
@ -71,7 +71,7 @@ msgstr ""
|
|||||||
msgid "confirm your memEx account"
|
msgid "confirm your memEx account"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/memex/accounts/email.ex:38
|
#: lib/memex/accounts/email.ex:37
|
||||||
#, elixir-autogen, elixir-format, fuzzy
|
#, elixir-autogen, elixir-format, fuzzy
|
||||||
msgid "reset your memEx password"
|
msgid "reset your memEx password"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -86,7 +86,7 @@ msgstr ""
|
|||||||
msgid "this email was sent from memEx at %{url}"
|
msgid "this email was sent from memEx at %{url}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/memex/accounts/email.ex:45
|
#: lib/memex/accounts/email.ex:43
|
||||||
#, elixir-autogen, elixir-format, fuzzy
|
#, elixir-autogen, elixir-format, fuzzy
|
||||||
msgid "update your memEx email"
|
msgid "update your memEx email"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -71,7 +71,7 @@ msgstr ""
|
|||||||
msgid "confirm your memEx account"
|
msgid "confirm your memEx account"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/memex/accounts/email.ex:38
|
#: lib/memex/accounts/email.ex:37
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "reset your memEx password"
|
msgid "reset your memEx password"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -86,7 +86,7 @@ msgstr ""
|
|||||||
msgid "this email was sent from memEx at %{url}"
|
msgid "this email was sent from memEx at %{url}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/memex/accounts/email.ex:45
|
#: lib/memex/accounts/email.ex:43
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "update your memEx email"
|
msgid "update your memEx email"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -72,7 +72,7 @@ msgstr ""
|
|||||||
msgid "confirm your memEx account"
|
msgid "confirm your memEx account"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/memex/accounts/email.ex:38
|
#: lib/memex/accounts/email.ex:37
|
||||||
#, elixir-autogen, elixir-format, fuzzy
|
#, elixir-autogen, elixir-format, fuzzy
|
||||||
msgid "reset your memEx password"
|
msgid "reset your memEx password"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -87,7 +87,7 @@ msgstr ""
|
|||||||
msgid "this email was sent from memEx at %{url}"
|
msgid "this email was sent from memEx at %{url}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/memex/accounts/email.ex:45
|
#: lib/memex/accounts/email.ex:43
|
||||||
#, elixir-autogen, elixir-format, fuzzy
|
#, elixir-autogen, elixir-format, fuzzy
|
||||||
msgid "update your memEx email"
|
msgid "update your memEx email"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
Loading…
Reference in New Issue
Block a user