ruby on rails - Combining 2 params to create the password when using Devise -
i'm using rails 4 devise , i've got situation need log in password made of 2 separate input fields. after submitting, need combine 2 inputs form password before params used authenticate them.
i know login details correct because if have single password field works expected.
as test i've tried submit blank password , intercept params in sessions controller temporarily hard coding correct password - e.g.
class sessionscontroller < devise::sessionscontroller def create params[:user][:password] = "abcde-12345" [... rest of standard devise sessions controller ... ] end end
but doesn't work. happening before hitting controller , pointers on how can intercept submitted parameters appreciated. code devise controller here:
https://github.com/plataformatec/devise/blob/master/app/controllers/devise/sessions_controller.rb
do need write custom warden strategy perhaps?
your test may have failed because authentication may have happened earlier before action processed (or before before_filter
callback). example, extension calls current_user
in execution chain. after altered params
, warden.authenticate!
still called strategies aren't performed because they've been performed before (when presumably current_user
called), that's how warden things.
so guess leaves 3 options:
- find authentication performed , alter params accordingly before it
- implement custom strategy
- override
params_auth_hash
method in initializer
Comments
Post a Comment