Class: Pixiurge::Authentication::AccountStorage

Inherits:
Object
  • Object
show all
Defined in:
lib/pixiurge/authentication.rb

Overview

This stores a collection of Pixiurge accounts. If you want to store accounts in a nonstandard way, this is the interface to match - inheritance could be a useful way to do it, but duck-typing is fine too. You can pass a AccountStorage into the constructor for a Pixiurge::AuthenticatedApp.

Since:

  • 0.1.0

Direct Known Subclasses

FileAccountStorage, MemStorage

Instance Method Summary collapse

Instance Method Details

#data_for(username) ⇒ Hash{String=>String}

Get user data for the named account.

Parameters:

  • username (String)

    The account's username

Returns:

  • (Hash{String=>String})

    The account's user data

Since:

  • 0.1.0



274
275
276
# File 'lib/pixiurge/authentication.rb', line 274

def data_for(username)
  raise "Override data_for to create a valid AccountStorage object!"
end

#register(username, account_data) ⇒ void

This method returns an undefined value.

Create an account. The account_data hash will contain information about the encrypted password hash in the default setup, but it's allowed to contain any JSON-serializable Hash in general.

Parameters:

  • username (String)

    The account's username; see AuthenticatedApp::USERNAME_REGEX for legal format

  • account_data (Hash{String})

    The user's data, normally including login info

Since:

  • 0.1.0



265
266
267
# File 'lib/pixiurge/authentication.rb', line 265

def register(username, )
  raise "Override register to create a valid AccountStorage object!"
end

#set_data_for(username, new_data) ⇒ void

This method returns an undefined value.

Set user data for the named account. Any fields not included in the new value are deleted.

Parameters:

  • username (String)

    The account's username

  • new_data (Hash{String=>String})

    The account's new user data

Since:

  • 0.1.0



285
286
287
# File 'lib/pixiurge/authentication.rb', line 285

def set_data_for(username, new_data)
  raise "Override set_data_for to create a valid AccountStorage object!"
end

#unregister(username) ⇒ void

This method returns an undefined value.

Unregister the named account; delete it from the AccountStorage.

Parameters:

  • username (String)

    The account's username

Since:

  • 0.1.0



294
295
296
# File 'lib/pixiurge/authentication.rb', line 294

def unregister(username)
  raise "Override unregister to create a valid AccountStorage object!"
end