When you press the "Easy Login" button, Installation of a button to log in as a registered guest user.
A web app based on the Rails tutorial.
Create an easy_login action separately from the create action of sessions_controller for registered guest users. Pass the email.
Describe the routing of easy_login in routs.rb.
Install the Easy Login
button in view.
Created and registered in sessions_controller.rb
(seeds.rb)
Add an easy_login action so that you can log in as a guest user.
sessions_controller.rb
def easy_login
user = User.find_by(email: "[email protected]")
log_in user #session_Predefined with helper.
redirect_back_or user #session_Predefined with helper.
end
config / routes.rb
config/routes.rb
post '/easy_login', to: 'sessions#easy_login'
app/views/sessions/new.html.erb
<p><%= link_to "Easy login", easy_login_path, method: :post, class: 'btn btn-primary' %></p>
For the time being, I was able to log in as a guest user from the easy login button.
Recommended Posts