mirror of
https://github.com/iritmaximus/brewery.git
synced 2026-10-12 19:13:49 +03:00
incorrect login redirects back to sign-in
This commit is contained in:
@@ -4,8 +4,12 @@ class SessionsController < ApplicationController
|
||||
|
||||
def create
|
||||
user = User.find_by username: params[:username]
|
||||
session[:user_id] = user.id if user
|
||||
redirect_to user
|
||||
if user.nil?
|
||||
redirect_to signin_path, notice: "User #{params[:username]} does not exist!"
|
||||
else
|
||||
session[:user_id] = user.id if user
|
||||
redirect_to user
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<p style="color: red"><%= notice %></p>
|
||||
|
||||
<h1>Sign in</h1>
|
||||
|
||||
<%= form_with url: session_path, method: :post do |form| %>
|
||||
|
||||
Reference in New Issue
Block a user