This commit is contained in:
bruckwubete
2018-06-29 10:08:58 -04:00
21 changed files with 463 additions and 46 deletions

View File

@ -155,7 +155,7 @@ class RoomsController < ApplicationController
def bring_to_room
if current_user
# Redirect authenticated users to their room.
redirect_to room_path(current_user.room)
redirect_to room_path(current_user.main_room)
else
# Redirect unauthenticated users to root.
redirect_to root_path

View File

@ -1,9 +1,7 @@
# frozen_string_literal: true
class SessionsController < ApplicationController
# GET /users/login
def new
end
LOGIN_FAILED = "Login failed due to invalid credentials. Are you sure you typed them correctly?"
# GET /users/logout
def destroy
@ -14,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
@ -35,6 +35,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