lib/generators/dailycred_generator.rb in dailycred-0.1.25 vs lib/generators/dailycred_generator.rb in dailycred-0.1.26

- old
+ new

@@ -8,10 +8,11 @@ APP_ROUTES_LINES =<<-EOS match '/auth/:provider/callback' => 'sessions#create' match "/logout" => "sessions#destroy", :as => :logout match "/auth" => "sessions#info", :as => :auth + match "/auth/dailycred" EOS APP_CONTROLLER_LINES =<<-EOS helper_method :current_user, :login_path, :dailycred, :signup_path @@ -31,20 +32,10 @@ # before_filter :authenticate def authenticate redirect_to auth_path unless current_user end - # link to sign up - def signup_path - "/auth/dailycred" - end - - # link to login - def login_path - "/auth/dailycred?action=signin" - end - # helper method for getting an instance of dailycred # example: # dailycred.tagUser "user_id", "tag" # # for more documentation, visit https://www.dailycred.com/api/ruby @@ -52,10 +43,17 @@ config = Rails.configuration @dailycred ||= Dailycred.new(config.DAILYCRED_CLIENT_ID, config.DAILYCRED_SECRET_KEY, config.dc_options) end EOS + APP_HELPER_LINES = <<-EOS + def connect_path(provider) + url = "/auth/dailycred?identity_provider=#{provider.to_s}" + url += "&referrer=#{request.protocol}#{request.host_with_port}#{request.fullpath}" + end + EOS + def install dailycred_ascii =<<-EOS ***** ***** ***** @@ -73,9 +71,11 @@ template "omniauth.rb", "config/initializers/omniauth.rb" # session_controller copy_file "sessions_controller.rb", "app/controllers/sessions_controller.rb" # application controller inject_into_class "app/controllers/application_controller.rb", ApplicationController, APP_CONTROLLER_LINES + # application helper + inject_into_class "app/helpers/application_helper.rb", ApplicationController, APP_HELPER_LINES # add user_model copy_file "user.rb", "app/models/user.rb" # session_controller copy_file "migration_create_user.rb", "db/migrate/#{Time.now.strftime('%Y%m%d%H%M%S')}_create_users.rb" # auth page