##// END OF EJS Templates
fixed dotted hr for IE6...
fixed dotted hr for IE6 git-svn-id: http://redmine.rubyforge.org/svn/trunk@305 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r233:d185e2f9e015
r302:909954ac342f
Show More
account_controller.rb
131 lines | 5.0 KiB | text/x-ruby | RubyLexer
/ app / controllers / account_controller.rb
Jean-Philippe Lang
Initial commit...
r2 # redMine - project management software
Jean-Philippe Lang
settings are now stored in the database (config_custom.rb no more used) and editable through the application in: Admin -> Settings...
r164 # Copyright (C) 2006-2007 Jean-Philippe Lang
Jean-Philippe Lang
Initial commit...
r2 #
# 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
Jean-Philippe Lang
v0.2.0...
r5 layout 'base'
Jean-Philippe Lang
0.3 unstable...
r10 helper :custom_fields
include CustomFieldsHelper
Jean-Philippe Lang
v0.2.0...
r5
Jean-Philippe Lang
Initial commit...
r2 # prevents login action to be filtered by check_if_login_required application scope filter
Jean-Philippe Lang
0.3 unstable...
r10 skip_before_filter :check_if_login_required, :only => [:login, :lost_password, :register]
Jean-Philippe Lang
lost_password option checking in account controller...
r233 before_filter :require_login, :only => :logout
Jean-Philippe Lang
Initial commit...
r2
Jean-Philippe Lang
0.3 unstable...
r10 # Show user's account
Jean-Philippe Lang
v0.2.0...
r5 def show
@user = User.find(params[:id])
Jean-Philippe Lang
* new report: project activity...
r42 @custom_values = @user.custom_values.find(:all, :include => :custom_field)
Jean-Philippe Lang
ActiveRecord::RecordNotFound exceptions handled more gracefully...
r130 rescue ActiveRecord::RecordNotFound
render_404
Jean-Philippe Lang
v0.2.0...
r5 end
# Login request and validation
def login
if request.get?
Jean-Philippe Lang
0.3 unstable...
r10 # Logout user
self.logged_in_user = nil
Jean-Philippe Lang
v0.2.0...
r5 else
Jean-Philippe Lang
0.3 unstable...
r10 # Authenticate user
user = User.try_to_login(params[:login], params[:password])
if user
self.logged_in_user = user
Jean-Philippe Lang
- new controller "myController"...
r60 redirect_back_or_default :controller => 'my', :action => 'page'
Jean-Philippe Lang
v0.2.0...
r5 else
Jean-Philippe Lang
Localization plugin removed (replaced with GLoc)...
r12 flash.now[:notice] = l(:notice_account_invalid_creditentials)
Jean-Philippe Lang
v0.2.0...
r5 end
end
end
Jean-Philippe Lang
Initial commit...
r2
Jean-Philippe Lang
0.3 unstable...
r10 # Log out current user and redirect to welcome page
def logout
self.logged_in_user = nil
Jean-Philippe Lang
* replaced :controller => '' broken statements by :controller => 'welcome'...
r172 redirect_to :controller => 'welcome'
Jean-Philippe Lang
0.3 unstable...
r10 end
# Enable user to choose a new password
def lost_password
Jean-Philippe Lang
lost_password option checking in account controller...
r233 redirect_to :controller => 'welcome' and return unless Setting.lost_password?
Jean-Philippe Lang
0.3 unstable...
r10 if params[:token]
@token = Token.find_by_action_and_value("recovery", params[:token])
Jean-Philippe Lang
* replaced :controller => '' broken statements by :controller => 'welcome'...
r172 redirect_to :controller => 'welcome' and return unless @token and !@token.expired?
Jean-Philippe Lang
0.3 unstable...
r10 @user = @token.user
if request.post?
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
if @user.save
@token.destroy
flash[:notice] = l(:notice_account_password_updated)
redirect_to :action => 'login'
return
end
end
render :template => "account/password_recovery"
return
else
if request.post?
Jean-Philippe Lang
Localization plugin removed (replaced with GLoc)...
r12 user = User.find_by_mail(params[:mail])
# user not found in db
flash.now[:notice] = l(:notice_account_unknown_email) and return unless user
# user uses an external authentification
flash.now[:notice] = l(:notice_can_t_change_password) and return if user.auth_source_id
# create a new token for password recovery
Jean-Philippe Lang
0.3 unstable...
r10 token = Token.new(:user => user, :action => "recovery")
if token.save
Mailer.deliver_lost_password(token)
flash[:notice] = l(:notice_account_lost_email_sent)
redirect_to :action => 'login'
return
end
end
end
end
# User self-registration
def register
Jean-Philippe Lang
* replaced :controller => '' broken statements by :controller => 'welcome'...
r172 redirect_to :controller => 'welcome' and return unless Setting.self_registration?
Jean-Philippe Lang
0.3 unstable...
r10 if params[:token]
token = Token.find_by_action_and_value("register", params[:token])
Jean-Philippe Lang
* replaced :controller => '' broken statements by :controller => 'welcome'...
r172 redirect_to :controller => 'welcome' and return unless token and !token.expired?
Jean-Philippe Lang
0.3 unstable...
r10 user = token.user
Jean-Philippe Lang
* replaced :controller => '' broken statements by :controller => 'welcome'...
r172 redirect_to :controller => 'welcome' and return unless user.status == User::STATUS_REGISTERED
Jean-Philippe Lang
0.3 unstable...
r10 user.status = User::STATUS_ACTIVE
if user.save
token.destroy
flash[:notice] = l(:notice_account_activated)
redirect_to :action => 'login'
return
end
else
if request.get?
Jean-Philippe Lang
settings are now stored in the database (config_custom.rb no more used) and editable through the application in: Admin -> Settings...
r164 @user = User.new(:language => Setting.default_language)
Jean-Philippe Lang
0.3 unstable...
r10 @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) }
else
@user = User.new(params[:user])
@user.admin = false
@user.login = params[:user][:login]
@user.status = User::STATUS_REGISTERED
@user.password, @user.password_confirmation = params[:password], params[:password_confirmation]
@custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) }
@user.custom_values = @custom_values
token = Token.new(:user => @user, :action => "register")
if @user.save and token.save
Mailer.deliver_register(token)
flash[:notice] = l(:notice_account_register_done)
Jean-Philippe Lang
* replaced :controller => '' broken statements by :controller => 'welcome'...
r172 redirect_to :controller => 'welcome' and return
Jean-Philippe Lang
0.3 unstable...
r10 end
end
end
end
Jean-Philippe Lang
Initial commit...
r2 end