Class: AccountController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- AccountController
- Includes:
- CustomFieldsHelper
- Defined in:
- app/controllers/account_controller.rb
Overview
Redmine - project management software Copyright © 2006-2009 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.
Instance Method Summary collapse
-
#activate ⇒ Object
Token based account activation.
-
#login ⇒ Object
Login request and validation.
-
#logout ⇒ Object
Log out current user and redirect to welcome page.
-
#lost_password ⇒ Object
Enable user to choose a new password.
-
#register ⇒ Object
User self-registration.
Methods included from CustomFieldsHelper
#custom_field_formats_for_select, #custom_field_label_tag, #custom_field_tag, #custom_field_tag_for_bulk_edit, #custom_field_tag_with_label, #custom_fields_tabs, #format_value, #render_api_custom_values, #show_value
Methods inherited from ApplicationController
accept_key_auth, #accept_key_auth_actions, #api_key_from_request, #api_offset_and_limit, #api_request?, #authorize, #authorize_global, #back_url, #check_if_login_required, #check_project_privacy, #check_project_uniqueness, #default_template, #delete_broken_cookies, #deny_access, #filename_for_content_disposition, #find_current_user, #find_issues, #find_model_object, #find_optional_project, #find_project, #find_project_by_project_id, #find_project_from_association, #invalid_authenticity_token, #logged_user=, model_object, #object_errors_to_json, #parse_qvalues, #per_page_option, #pick_layout, #query_statement_invalid, #redirect_back_or_default, #render_403, #render_404, #render_attachment_warning_if_needed, #render_error, #render_feed, #render_validation_errors, #require_admin, #require_login, #set_flash_from_bulk_issue_save, #set_localization, #use_layout, #user_setup
Methods included from Redmine::MenuManager::MenuController
#current_menu_item, included, #menu_items, #redirect_to_project_menu_item
Methods included from Redmine::Search::Controller
#default_search_scope, #default_search_scopes, included
Methods included from Redmine::I18n
#current_language, #day_name, #find_language, #format_date, #format_time, included, #l, #l_hours, #l_or_humanize, #ll, #month_name, #set_language_if_valid, #valid_languages
Instance Method Details
#activate ⇒ Object
Token based account activation
114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'app/controllers/account_controller.rb', line 114 def activate redirect_to(home_url) && return unless Setting.self_registration? && params[:token] token = Token.find_by_action_and_value('register', params[:token]) redirect_to(home_url) && return unless token and !token.expired? user = token.user redirect_to(home_url) && return unless user.registered? user.activate if user.save token.destroy flash[:notice] = l(:notice_account_activated) end redirect_to :action => 'login' end |
#login ⇒ Object
Login request and validation
26 27 28 29 30 31 32 |
# File 'app/controllers/account_controller.rb', line 26 def login if request.get? logout_user else authenticate_user end end |
#logout ⇒ Object
Log out current user and redirect to welcome page
35 36 37 38 |
# File 'app/controllers/account_controller.rb', line 35 def logout logout_user redirect_to home_url end |
#lost_password ⇒ Object
Enable user to choose a new password
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/controllers/account_controller.rb', line 41 def lost_password redirect_to(home_url) && return unless Setting.lost_password? if params[:token] @token = Token.find_by_action_and_value("recovery", params[:token]) redirect_to(home_url) && return unless @token and !@token.expired? @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? user = User.find_by_mail(params[:mail]) # user not found in db (flash.now[:error] = l(:notice_account_unknown_email); return) unless user # user uses an external authentification (flash.now[:error] = l(:notice_can_t_change_password); return) if user.auth_source_id # create a new token for password recovery 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 |
#register ⇒ Object
User self-registration
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'app/controllers/account_controller.rb', line 78 def register redirect_to(home_url) && return unless Setting.self_registration? || session[:auth_source_registration] if request.get? session[:auth_source_registration] = nil @user = User.new(:language => Setting.default_language) else @user = User.new(params[:user]) @user.admin = false @user.register if session[:auth_source_registration] @user.activate @user.login = session[:auth_source_registration][:login] @user.auth_source_id = session[:auth_source_registration][:auth_source_id] if @user.save session[:auth_source_registration] = nil self.logged_user = @user flash[:notice] = l(:notice_account_activated) redirect_to :controller => 'my', :action => 'account' end else @user.login = params[:user][:login] @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] case Setting.self_registration when '1' register_by_email_activation(@user) when '3' register_automatically(@user) else register_manually_by_administrator(@user) end end end end |