Mask on login devise

How I put a mask on login with devise?

This is my views/devise/sessions/new.html.erb

<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>

<%= f.input :cpf, required: false, autofocus: true, input_html: { class: ‘form-control mask-cpf’ }, placeholder: ‘LOGIN’, label: false %>

<%= f.input :password, required: false, input_html: { class: ‘form-control’ }, placeholder: ‘SENHA’, label: false %>

<%= f.button :submit, “Log in”, :class => “btn btn-default btn-lg btn-block” %>

<% end %>

I need generate the sessions_controller of the devise? Or I just use in User.rb? The mask appear, but when save, save with . and - , because this I cant sign_in :frowning:

My class User, this:

class User < ActiveRecord::Base

devise :database_authenticatable, :registerable,

:recoverable, :rememberable, :trackable, :validatable

before_validation do

self.cpf.gsub!(/(.|-)/, “”)


validates :cpf, uniqueness: true