SORU
5 EYLÜL 2013, PERŞEMBE


Vasiyet "Onay token geçersiz" kullanıcı siteye üye olduğunda

4 Raylar ve benim web 3.1.0 uygulama Hazırlamak. Kullanıcı oturum test Salatalık bir test; "" bağlantı e-posta. tıklandığında hesabımı onaylamak başarısız yazdım

Scenario: User signs up with valid data                                                           # features/users/sign_up.feature:9
    When I sign up with valid user data                                                             # features/step_definitions/user_steps.rb:87
    Then I should receive an email                                                                  # features/step_definitions/email_steps.rb:51
    When I open the email                                                                           # features/step_definitions/email_steps.rb:76
    Then I should see the email delivered from "no-reply@mysite.com"                                # features/step_definitions/email_steps.rb:116
    And I should see "You can confirm your account email through the link below:" in the email body # features/step_definitions/email_steps.rb:108
    When I follow "Confirm my account" in the email                                                 # features/step_definitions/email_steps.rb:178
    Then I should be signed in                                                                      # features/step_definitions/user_steps.rb:142
      expected to find text "Logout" in "...Confirmation token is invalid..." (RSpec::Expectations::ExpectationNotMetError)
     ./features/step_definitions/user_steps.rb:143:in `/^I should be signed in$

Ben bu hatayı el ile web sunucusu üzerinden de kayıt olduğunuzda tekrarlanabilir, Salatalık bir sorun görünmüyor.

İstiyorum:

  • Tek tıkla edebilmek için kullanıcının e-posta bu bağlantı yoluyla hesabı onaylayın
  • Kullanıcı hesabı onayladıktan sonra oturum açık kalsın

Kurulum var:

  • En son kod, GitHub dan Vasiyet (3.1.0 hakem 041fcf90807df5efded5fdcd53ced80544e7430f)
  • confirmable uygulayan User bir sınıf
  • 'Varsayılan' onay denetleyici (benim kendi özel bir tanımlı değil).

Bu mesaj okudum:

Ve denedim:

  • Başlatıcı Hazırlamak benim config.allow_insecure_tokens_lookup = true ayar, bir 'bilinmeyen yöntem' başlatma hatası. atar Ayrıca bu kullanarak önlemek istiyorum yani geçici bir düzeltme olması gerekiyor. sadece benziyor.
  • Benim DB temizlendi ve çizik yok eski simgeleri mevcut) başladı

Güncelleme:

Onay belirteci denetimi kayıttan sonra User saklı. E-posta simgesi DBs token ile eşleşir. Mesaj yukarıdaki göre, yeni Vasiyet davranışı gerek yok, bunun yerine ikinci bir belirteç e-posta belirtecini temel oluştursun olduğunu söylüyor.Bu şüpheli.User.confirm_by_token('[EMAIL_CONFIRMATION_TOKEN]') çalışan döner hataları "@mesaj={:confirmation_token=>kuran bir Kullanıcı ["geçersiz"]} sorunun kaynağı gibi görünüyor.",

Eşleşmeyen belirteçleri sorunun kalbi gibi görünüyor, aşağıdaki kodu konsol el ile Kullanıcı değiştirmek için confirmation_token koşu onay başarılı olmak için nedenler:

new_token = Devise.token_generator.digest(User, :confirmation_token, '[EMAIL_TOKEN]')
u = User.first
u.confirmation_token = new_token
u.save
User.confirm_by_token('[EMAIL_TOKEN]') # Succeeds

Neden yanlış onay ilk etapta DB token tasarrufu mu? Özel bir kayıt denetleyicisi kullanıyorum... belki yanlış ayarlanmasına neden bir şeyler var?

yolları.rb

  devise_for  :users,
          :path => '',
          :path_names => {
            :sign_in => 'login',
            :sign_out => 'logout',
            :sign_up => 'register'
            },
          :controllers => {
            :registrations => "users/registrations",
            :sessions => "users/sessions"
          }

kullanıcılar registrations_controller/.rb:

class Users::RegistrationsController < Devise::RegistrationsController

  def create
    # Custom code to fix DateTime issue
    Utils::convert_params_date_select params[:user][:profile_attributes], :birthday, nil, true

    super
  end

  def sign_up_params
    # TODO: Still need to fix this. Strong parameters with nested attributes not working.
    #       Permitting all is a security hazard.
    params.require(:user).permit!
    #params.require(:user).permit(:email, :password, :password_confirmation, :profile_attributes)
  end
  private :sign_up_params
end

CEVAP
7 EYLÜL 2013, CUMARTESİ


3.1.0 Hazırlamak için yükseltme bazı 'işe yaramayan öğeleri' bir süredir dokunmadım etmedim bir görünümde. sol

Değiştirmek için gereken this blog post göre senin mailer @token yerine eski @resource.confirmation_token kullanmak için Hazırlamak.

app/views/<user>/mailer/confirmation_instructions.html.erb Bu bulmak ve böyle bir şey için değiştirin:

<p>Welcome <%= @resource.email %>!</p>
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @token) %></p>

Bu geçiriyorsun belirteci tabanlı herhangi bir onay sorunu çözmek gerekir. Bu kilidini açmak için herhangi bir düzeltme veya şifre token sorunlarını sıfırlamak için muhtemeldir.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • EminemMusic

    EminemMusic

    9 ŞUBAT 2007
  • SegaAmerica

    SegaAmerica

    5 Mart 2008
  • The CGBros

    The CGBros

    20 AĞUSTOS 2011