Commit cc44859b authored by Michel Felipe de Oliveira Ferreira's avatar Michel Felipe de Oliveira Ferreira
Browse files

Apply suggestions of @brauliobo. Change the scope of UserNotActive exception...

Apply suggestions of @brauliobo. Change the scope of UserNotActive exception to User model namespace
parent f0214e00
......@@ -48,7 +48,7 @@ class AccountController < ApplicationController
begin
self.current_user ||= User.authenticate(params[:user][:login], params[:user][:password], environment) if params[:user]
rescue NoosferoExceptions::UserNotActivated => e
rescue User::UserNotActivated => e
session[:notice] = e.message
return
end
......
......@@ -242,11 +242,21 @@ class User < ActiveRecord::Base
password.crypt(salt)
end
class UserNotActivated < StandardError
attr_reader :user
def initialize(message, user = nil)
@user = user
super(message)
end
end
def authenticated?(password)
unless self.activated?
message = _('The user "%{login}" is not activated! Please check your email to activate your user') % {login: self.login}
raise NoosferoExceptions::UserNotActivated.new(message, self)
raise UserNotActivated.new(message, self)
end
result = (crypted_password == encrypt(password))
......@@ -293,9 +303,9 @@ class User < ActiveRecord::Base
self.errors.add(:current_password, _('does not match.'))
raise IncorrectPassword
end
rescue NoosferoExceptions::UserNotActivated => e
rescue UserNotActivated => e
self.errors.add(:current_password, e.message)
raise IncorrectPassword
raise UserNotActivated
end
self.force_change_password!(new, confirmation)
end
......@@ -411,15 +421,3 @@ class User < ActiveRecord::Base
Delayed::Job.enqueue(UserActivationJob.new(self.id), {:priority => 0, :run_at => (NOOSFERO_CONF['hours_until_user_activation_check'] || 72).hours.from_now})
end
end
module NoosferoExceptions
class UserNotActivated < ActiveRecord::ActiveRecordError
attr_reader :user
def initialize(message, user = nil)
@user = user
super(message)
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment