From 5f27e09eda7df8a9eea0091dd0120856632972e1 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Jun 2018 18:26:42 -0300 Subject: [PATCH] loguear mejor los login --- lib/warden/imap.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/warden/imap.rb b/lib/warden/imap.rb index a17ce5a..a5f5646 100644 --- a/lib/warden/imap.rb +++ b/lib/warden/imap.rb @@ -12,7 +12,11 @@ module Warden return false unless params.include? 'username' return false unless params.include? 'password' - @email = EmailAddress.new(params['username']) + username = params['username'] + + @email = EmailAddress.new(username, host_validation: :a) + + Rails.logger.error [username, @email.error].join(': ') unless @email.valid? @email.valid? end @@ -32,17 +36,20 @@ module Warden rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT, Errno::ENETUNREACH, SocketError, Net::IMAP::ByeResponseError => e + Rails.logger.error e.to_s @imap.disconnect fail! e.to_s end def imap_login + Rails.logger.info "Autenticando a #{@email.normal}" @imap.login(@email.normal, params['password']) @imap.disconnect success! Usuaria.find(@email.normal) - rescue EOFError => e + rescue Net::IMAP::NoResponseError, EOFError => e @imap.disconnect + Rails.logger.error e.to_s fail! e.to_s end end