test sessions controller and fix style

This commit is contained in:
Joshua Arts
2018-06-27 17:00:37 -04:00
parent 337345560d
commit a6b313f38e
7 changed files with 120 additions and 23 deletions

View File

@ -1,10 +1,6 @@
# frozen_string_literal: true
class SessionsController < ApplicationController
# GET /users/login
def new
end
# GET /users/logout
def destroy
logout
@ -14,7 +10,7 @@ class SessionsController < ApplicationController
# POST /users/login
def create
user = User.find_by(email: session_params[:email])
if user.&authenticate(session_params[:password])
if user&.authenticate(session_params[:password])
login(user)
end
end
@ -35,6 +31,9 @@ class SessionsController < ApplicationController
def omniauth
user = User.from_omniauth(request.env['omniauth.auth'])
login(user)
rescue => e
logger.error "Error authenticating via omniauth: #{e}"
redirect_to root_path
end
# POST /auth/failure