Sha256: 75f4ef52f6d4288ce147a7798267477ea729ee7550c7dd94c11cc0013d9d9eb0

Contents?: true

Size: 624 Bytes

Versions: 10

Compression:

Stored size: 624 Bytes

Contents

# frozen_string_literal: true

require 'ditty/policies/application_policy'

module Ditty
  class IdentityPolicy < ApplicationPolicy
    def login?
      true
    end

    def forgot_password?
      true
    end

    def reset_password?
      record.new? || (record.reset_requested && record.reset_requested > (Time.now - (24 * 60 * 60)))
    end

    def permitted_attributes
      %i[username password password_confirmation]
    end

    class Scope < ApplicationPolicy::Scope
      def resolve
        if user.super_admin?
          scope
        else
          scope.where(id: -1)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ditty-0.11.1 lib/ditty/policies/identity_policy.rb
ditty-0.10.2 lib/ditty/policies/identity_policy.rb
ditty-0.10.1 lib/ditty/policies/identity_policy.rb
ditty-0.9.1 lib/ditty/policies/identity_policy.rb
ditty-0.9.0 lib/ditty/policies/identity_policy.rb
ditty-0.8.0 lib/ditty/policies/identity_policy.rb
ditty-0.7.2 lib/ditty/policies/identity_policy.rb
ditty-0.7.1 lib/ditty/policies/identity_policy.rb
ditty-0.7.0 lib/ditty/policies/identity_policy.rb
ditty-0.7.0.pre.rc1 lib/ditty/policies/identity_policy.rb