मैं devise_token_auth
संस्करण 0.1.38
का उपयोग कर किसी मौजूदा उपयोगकर्ता प्रवेश करने के लिए कोशिश कर रहा हूँ, लेकिन मैं में एक IndexError: string not matched
मार रहा हूँ लाइब्रेरी की sessions_controller
।devise_token_auth और रेल 5 - IndexError: स्ट्रिंग मिलान नहीं
IndexError (string not matched):
devise_token_auth (0.1.38) app/controllers/devise_token_auth/sessions_controller.rb:37:in `[]='
devise_token_auth (0.1.38) app/controllers/devise_token_auth/sessions_controller.rb:37:in `create'
actionpack (5.0.0) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
actionpack (5.0.0) lib/abstract_controller/base.rb:188:in `process_action'
actionpack (5.0.0) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.0.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
प्रासंगिक कोड sessions_controller
से है:
if @resource and valid_params?(field, q_value) and @resource.valid_password?(resource_params[:password]) and ([email protected]_to?(:active_for_authentication?) or @resource.active_for_authentication?)
# create client id
@client_id = SecureRandom.urlsafe_base64(nil, false)
@token = SecureRandom.urlsafe_base64(nil, false)
# !! Next line is line 37 with the error !!
@resource.tokens[@client_id] = {
token: BCrypt::Password.create(@token),
expiry: (Time.now + DeviseTokenAuth.token_lifespan).to_i
}
@resource.save
sign_in(:user, @resource, store: false, bypass: false)
मैं एक मौजूदा परियोजना के लिए devise_token_auth
जोड़ दिया है तो यह बहुत संभव है कि मैं tokens
कॉलम में बुरा डेटा बना लिया है। मैंने sessions_controller
में कोड की नकल करने सहित अपने मौजूदा उपयोगकर्ताओं में token
जेसन को डिफॉल्ट करने के विभिन्न तरीकों का प्रयास किया है।
add_column :users, :tokens, :json, null: false, default: {}
User.reset_column_information
client_id = SecureRandom.urlsafe_base64(nil, false)
token = SecureRandom.urlsafe_base64(nil, false)
User.find_each do |user|
user.uid = user.email
user.provider = 'email'
user.tokens[client_id] = {
token: BCrypt::Password.create(token),
expiry: (Time.now + DeviseTokenAuth.token_lifespan).to_i
}
user.save!
end
मैं issue #101 में इस का उल्लेख देखा है, लेकिन है कि एक विशेष संकल्प नहीं था। कोई विचार जहां मैं गलत जा रहा हूँ?
मेरे लिए, यह केवल तब होता है जब मैं हेरोोक पर अपने रेल ऐप चलाता हूं। मेरे स्थानीय उदाहरण में यह समस्या नहीं है। मैंने देखा कि मेरे पोस्टग्रेज़ संस्करण (9.6.2) स्थानीय रूप से हेरोकू संस्करण (9.6.4) से भिन्न थे। सुनिश्चित नहीं है कि यह समस्या पैदा कर रहा है या नहीं –