In my app I need to have a database authentication but without a password. Just by entering your phone number. When the user sings up he enter phone number, adress and name and no password.
Is it real? Just can't figure out how to make it.
Thanks for help in advance!
Figured out like this:
In devise_no_pass.rb initializer add:
require 'devise/strategies/authenticatable'
module Devise
module Strategies
class DeviseNoPass < Authenticatable
def authenticate!
return super unless params[:customer_sign_in]
customer = Customer.find_by_phone(params[:customer_sign_in]
customer ? success!(customer) : raise
end
end
end
end
Warden::Strategies.add(:devise_no_pass, Devise::Strategies::DeviseNoPass)
In devise.rb:
config.warden do |manager|
manager.default_strategies(:scope => :customer).unshift :devise_no_pass
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With