title: What is a good strategy for adding Omniauth to and existing authentication method with Rails 4
body: <p>I am building a rails app and I already built a basic authentication with has_secure_password.However I would like to add facebook and twitter authentication on top of that.Here is my authentication</p>
  
  <p>User.rb</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    before_create :create_remember_token
  
    has_secure_password
  
    validates :name, presence: true
    VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
    validates :email, presence: true, uniqueness: true, format: {with:  VALID_EMAIL_REGEX }
    validates :last_name, presence: true 
  
    def User.new_remember_token
      SecureRandom.urlsafe_base64
    end
  
    def User.encrypt(token)
      Digest::SHA1.hexdigest(token.to_s)
    end
  
    private
  
    def create_remember_token
      self.remember_token = User.encrypt(User.new_remember_token)
    end
  end
  </code></pre>
  
  <p>SessionsController</p>
  
  <pre><code>class SessionsController &lt; ApplicationController
    def new
    end
  
    def create
      user = User.find_by(email: params[:session][:email])
      if user &amp;&amp; user.authenticate(params[:session][:password])
        sign_in user
        redirect_to users_path(user), success: 'Başarılı bir şekilde giriş yapıldı!'
      else
        redirect_to root_path, danger: 'Giriş sırasında sorun oluştu lütfen bilgilerin doğruluğunu kontrol et' 
      end
    end
  
    def destroy
      sign_out
      redirect_to root_path, success: 'Başarılı bir şekilde çıkış yapıldı.' 
    end
  end
  </code></pre>
  
  <p>SessionsHelper</p>
  
  <p>module SessionsHelper</p>
  
  <pre><code>  def sign_in(user)
      remember_token = User.new_remember_token
      if params[:remember_me]
        cookies.permanent[:remember_token] = remember_token
      else 
        cookies[:remember_token] = remember_token
      end
      user.update_attribute(:remember_token, User.encrypt(remember_token))
      self.current_user = user
    end
  
    def current_user=(user)
      @current_user = user
    end
  
    def current_user
      remember_token = User.encrypt(cookies[:remember_token])
      @current_user ||=  User.find_by(remember_token: remember_token)
    end
  
    def signed_in?
      !current_user.nil?
    end
  
    def sign_out
      self.current_user = nil 
      cookies.delete(:remember_token) 
    end
  end
  </code></pre>
  
  <p>So I want to add Facebook and Twitter authentication through Omniauth on top of this but I am not sure what the best strategy is to do this.Is it possible or do I have to completely change the way I am authenticating right now?</p>