Project

General

Profile

Defect #5302 » back_url.v.0.2.patch

Oleg Volkov, 2010-04-20 06:56

View differences:

redmine/app/controllers/account_controller.rb 2010-04-20 08:10:39.403029646 +0400
150 150

  
151 151
  
152 152
  def open_id_authenticate(openid_url)
153
    cookies[:back_url] = { :value => CGI.unescape(params[:back_url].to_s) } unless params[:open_id_complete]
153 154
    authenticate_with_open_id(openid_url, :required => [:nickname, :fullname, :email], :return_to => signin_url) do |result, identity_url, registration|
154 155
      if result.successful?
155 156
        user = User.find_or_initialize_by_identity_url(identity_url)
redmine/app/controllers/application_controller.rb 2010-04-20 08:10:39.404033104 +0400
177 177

  
178 178
  def redirect_back_or_default(default)
179 179
    back_url = CGI.unescape(params[:back_url].to_s)
180
    if back_url.blank?
181
      back_url = cookies[:back_url]
182
      cookies.delete :back_url
183
    end
180 184
    if !back_url.blank?
181 185
      begin
182 186
        uri = URI.parse(back_url)
redmine/test/functional/account_controller_test.rb 2010-04-20 08:49:39.123404798 +0400
67 67
    assert_redirected_to 'my/page'
68 68
  end
69 69

  
70
  def test_login_should_redirect_to_back_url_param_with_openid
71
    Setting.self_registration = '3'
72
    Setting.openid = '1'
73
    existing_user = User.new(:firstname => 'Cool',
74
                             :lastname => 'User',
75
                             :mail => 'user@somedomain.com',
76
                             :identity_url => 'http://openid.example.com/good_user')
77
    existing_user.login = 'cool_user'
78
    assert existing_user.save!
79

  
80
    post :login, :openid_url => existing_user.identity_url, :back_url => 'http%3A%2F%2Ftest.host%2Fissues%2Fshow%2F1'
81
    assert_redirected_to '/issues/show/1'
82
  end
83

  
70 84
  def test_login_with_openid_for_existing_non_active_user
71 85
    Setting.self_registration = '2'
72 86
    Setting.openid = '1'
(3-3/3)