Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Add registration by login and password #63

Merged

Conversation

NikitaNaumenko
Copy link
Contributor

No description provided.

@NikitaNaumenko NikitaNaumenko changed the title Add registration by login and password(WIP) Add registration by login and password Aug 8, 2019
|> subject(subject)
|> put_html_layout({HexletBasicsWeb.LayoutView, "email.html"})
|> render(
"user/reset_password.#{locale}.html",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

если не будет такого файла? мне кажется, ты даже не узнаешь об этом

end

defp sending_from(conn) do
"noreply@#{conn.host}"
Copy link

@tank-bohr tank-bohr Aug 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вот это не очень хорошо. лучше брать адрес из конфига.
ты отрезаешь себе возможность отправлять письма вне http-запроса

conn
|> put_flash(:info, gettext("Message with instructions for reset password was sent"))
|> redirect(to: "/")
else

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вот этот кусок третий раз вижу. можно вынести в plug


def delete(conn, _params) do
conn
|> put_flash(:info, gettext "You have been logged out!")
|> configure_session(drop: true)
|> redirect(to: "/")
end

defp check_authentication(conn, _options) do
%{assigns: %{current_user: current_user}} = conn

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можно прямо в параметрах паттерн-матчить

case Repo.insert(changeset) do
{:ok, user} ->

# TODO: пока отключил посылку писем с потдверждением

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

сделай ишью, не оставляй мусор в коде

@@ -0,0 +1,5 @@
defmodule HexletBasicsWeb.Helpers.CustomUrl do
def build_url(conn, path) do
"#{conn.scheme}://#{conn.host}#{path}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вот не люблю я полагаться на host. Так-то он из заголовков берется. Его можно любой подсунуть. Если твой nginx не настроен специальным образом, то он тебе от пользуна тут может вообще что угодно прилететь

end
end

defp check_authentication(conn, options) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Судя по всему этот плаг можно расширить.

@@ -2,6 +2,10 @@ defmodule HexletBasicsWeb.Router do
use HexletBasicsWeb, :router
use Plug.ErrorHandler

if Mix.env == :dev do
forward "/sent_emails", Bamboo.SentEmailViewerPlug
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Из любимого Кирилла

@PlugIN73 PlugIN73 merged commit 2289c12 into hexlet-basics:master Aug 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants