# Redmine - project management software
-# Copyright (C) 2006-2009 Jean-Philippe Lang
+# Copyright (C) 2006-2011 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class AccountController < ApplicationController
helper :custom_fields
- include CustomFieldsHelper
-
+ include CustomFieldsHelper
+
# prevents login action to be filtered by check_if_login_required application scope filter
skip_before_filter :check_if_login_required
logout_user
redirect_to home_url
end
-
+
# Enable user to choose a new password
def lost_password
redirect_to(home_url) && return unless Setting.lost_password?
flash[:notice] = l(:notice_account_password_updated)
redirect_to :action => 'login'
return
- end
+ end
end
render :template => "account/password_recovery"
return
end
end
end
-
+
# User self-registration
def register
redirect_to(home_url) && return unless Setting.self_registration? || session[:auth_source_registration]
end
end
end
-
+
# Token based account activation
def activate
redirect_to(home_url) && return unless Setting.self_registration? && params[:token]
end
redirect_to :action => 'login'
end
-
+
private
-
+
def logout_user
if User.current.logged?
cookies.delete :autologin
self.logged_user = nil
end
end
-
+
def authenticate_user
if Setting.openid? && using_open_id?
open_id_authenticate(params[:openid_url])
end
end
-
def open_id_authenticate(openid_url)
authenticate_with_open_id(openid_url, :required => [:nickname, :fullname, :email], :return_to => signin_url) do |result, identity_url, registration|
if result.successful?
register_manually_by_administrator(user) do
onthefly_creation_failed(user)
end
- end
+ end
else
# Existing record
if user.active?
end
end
end
-
+
def successful_authentication(user)
# Valid user
self.logged_user = user
call_hook(:controller_account_success_authentication_after, {:user => user })
redirect_back_or_default :controller => 'my', :action => 'page'
end
-
+
def set_autologin_cookie(user)
token = Token.create(:user => user, :action => 'autologin')
cookie_name = Redmine::Configuration['autologin_cookie_name'] || 'autologin'
yield if block_given?
end
end
-
+
# Automatically register a user
#
# Pass a block for behavior when a user fails to save
yield if block_given?
end
end
-
+
# Manual activation by the administrator
#
# Pass a block for behavior when a user fails to save