Sha256: 23a4f384af1e27e177c290838a8a69b4fc07201fc7935b16ac361b281bc287e4

Contents?: true

Size: 1 KB

Versions: 8

Compression:

Stored size: 1 KB

Contents

module Monban
  module UseCase
    module Auth
      module Token
        module Helper
          private

            def generate_public_id!(account_id:)
              i = 0
              while i < 100 do
                i += 1

                public_id = token.create
                unless repository.public_id_exists?(public_id: public_id)
                  repository.insert_public_id(
                    account_id: account_id,
                    public_id:  public_id,
                    created_at: time.now,
                    expired_at: time.now + expire,
                  )

                  logger.log(generate_public_id: {
                    account_id: account_id,
                    public_id:  public_id,
                    login_id:   repository.login_id(account_id: account_id),
                  })

                  return public_id
                end
              end

              error.server_error! "failed generate public_id"
            end

        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
monban-core-1.2.4 lib/monban/use_case/auth/token.rb
monban-core-1.2.3 lib/monban/use_case/auth/token.rb
monban-core-1.2.2 lib/monban/use_case/auth/token.rb
monban-core-1.1.0 lib/monban/use_case/auth/token.rb
monban-core-1.0.3 lib/monban/use_case/auth/token.rb
monban-core-1.0.2 lib/monban/use_case/auth/token.rb
monban-core-1.0.0 lib/monban/use_case/auth/token.rb
monban-core-0.1.0 lib/monban/use_case/auth/token.rb