Improve login form
This commit is contained in:
parent
88ccf7d958
commit
db908d4ea4
|
@ -10,7 +10,8 @@ class SessionsController < ApplicationController
|
||||||
session[:user_id] = @user.id
|
session[:user_id] = @user.id
|
||||||
redirect_to @user, notice: t(".logged_in")
|
redirect_to @user, notice: t(".logged_in")
|
||||||
else
|
else
|
||||||
redirect_to root_path, alert: t(".login_fail")
|
flash.now.alert = t(".login_fail")
|
||||||
|
render :new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<% @title = "Log in" %>
|
<% @title = "Log in" %>
|
||||||
<%= form_with url: sessions_path, method: :post do |f| %>
|
<%= form_with url: sessions_path, method: :post, id: "session_form" do |f| %>
|
||||||
<h2><%= t ".log_in" %></h2>
|
<h2><%= t ".log_in" %></h2>
|
||||||
|
|
||||||
<%= f.label :username %>
|
<%= f.label :username %>
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<% @title = "Log in" %>
|
||||||
|
<%= turbo_stream.replace "flash_wrapper" do %>
|
||||||
|
<%= render "shared/flash" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= turbo_stream.replace "session_form" do %>
|
||||||
|
<%= form_with url: sessions_path, method: :post, id: "session_form" do |f| %>
|
||||||
|
<h2><%= t ".log_in" %></h2>
|
||||||
|
|
||||||
|
<%= f.label :username %>
|
||||||
|
<%= f.text_field :username %>
|
||||||
|
|
||||||
|
<%= f.label :password %>
|
||||||
|
<%= f.password_field :password %>
|
||||||
|
|
||||||
|
<%= f.submit t(".log_in") %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
Loading…
Reference in New Issue