Sha256: 481486eda1a383e93fbb32a75ff7cdf9348747112ea15fb133090c83aec41ccc

Contents?: true

Size: 1.82 KB

Versions: 3

Compression:

Stored size: 1.82 KB

Contents

module Notifiers
  class Services < Controll::Notify::Typed
    class Base < Controll::Notify::Base
      def provider_name
        provider.capitalize
      end

      def service_name
        service_route.capitalize
      end

      def full_route
        service_route + '/' + provider_name
      end
    end

    class ErrorHandler < Base
      type :error

      def messages
        {
          must_sign_in: 'You need to sign in before accessing this page!',
          
          auth_service_error: %q{There was an error at the remote authentication service.
You have not been signed in.},
          
          cant_delete_current_account: 'You are currently signed in with this account!',
          user_save_error: 'This is embarrassing! There was an error while creating your account from which we were not able to recover.',
        }
      end

      def bad
        'bad stuff!'
      end

      def auth_error!
        'Error while authenticating via ' + service_name + '. The service did not return valid data.'
      end

      def auth_invalid!
        'Error while authenticating via {{full_route}}. The service returned invalid data for the user id.'
      end
    end

    class NoticeHandler < Base
      # for :signed_in and :signed_out - defined in locale file under:

      # services:
      #   notice:
      #     signed_in:  'Your account has been created and you have been signed in!'
      #     signed_out: 'You have been signed out!'

      def already_connected
        'Your account at {{provider_name}} is already connected with this site.'
      end

      def account_added
        'Your {{provider_name}} account has been added for signing in at this site.'
      end

      def sign_in_success
        'Signed in successfully via {{provider_name}}.'
      end

      def hello
        'hello you'
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
controll-0.3.2 spec/controll/notify/services_notifier.rb
controll-0.3.1 spec/controll/notify/services_notifier.rb
controll-0.3.0 spec/controll/notify/services_notifier.rb