Merge branch master into tests

This commit is contained in:
Joshua Arts
2018-06-28 11:29:30 -04:00
11 changed files with 34 additions and 26 deletions

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true
class SessionsController < ApplicationController
LOGIN_FAILED = "Login failed due to invalid credentials. Are you sure you typed them correctly?"
# GET /users/logout
def destroy
logout
@ -10,8 +12,10 @@ class SessionsController < ApplicationController
# POST /users/login
def create
user = User.find_by(email: session_params[:email])
if user&.authenticate(session_params[:password])
if user.try(:authenticate, session_params[:password])
login(user)
else
redirect_to root_path, notice: LOGIN_FAILED
end
end