Allow whitespace on signin. Fix bug in session messaging

This commit is contained in:
Seth Call 2018-03-08 07:23:39 -06:00
parent 6a4e099a18
commit c6486b82bf
2 changed files with 19 additions and 6 deletions

View File

@ -26,9 +26,16 @@ module JamRuby
def self.create(user, music_session, message, channel, client_id, target_user = nil, lesson_session = nil, purpose = nil, music_notation = nil, recording = nil)
source_user = user
# we hide the real source user; always make it from the teacher
if lesson_session && user.id != lesson_session.student_id
source_user = lesson_session.teacher
if lesson_session # force the messaging to be to/from
if user.id != lesson_session.student_id
source_user = lesson_session.teacher
target_user = lesson_session.student
else
source_user = lesson_session.student
target_user = lesson_session.teacher
end
end
chat_msg = ChatMessage.new
chat_msg.user_id = source_user.id
@ -111,6 +118,7 @@ module JamRuby
end
end
def send_chat_msg(music_session, chat_msg, user, client_id, channel, lesson_session, purpose, target_user, music_notation, claimed_recording)
music_session_id = music_session.id if music_session
@ -154,8 +162,8 @@ module JamRuby
elsif channel == 'global'
@@mq_router.publish_to_active_clients(msg)
elsif channel == 'lesson'
@@mq_router.publish_to_user(target_user.id, msg, sender = {:client_id => client_id})
@@mq_router.publish_to_user(user.id, msg, sender = {:client_id => client_id})
@@mq_router.publish_to_user(target_user.id, msg, sender = {:client_id => client_id}) if target_user
@@mq_router.publish_to_user(user.id, msg, sender = {:client_id => client_id}) if user
end
end

View File

@ -21,7 +21,12 @@ class SessionsController < ApplicationController
end
def create
user = User.authenticate(params[:session][:email], params[:session][:password])
email = params[:session][:email]
password = params[:session][:password]
email.strip! if email
password.strip! if password
user = User.authenticate(email, password)
if user.nil?
@login_error = true