Class SpazAccounts

Defined in: spazaccounts.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
SpazAccounts((Object))

This creates a new SpazAccounts object, and optionally associates it with an existing preferences object

Field Summary
Field Attributes Field Name and Description
 

the key used inside the prefs object

Method Summary
Method Attributes Method Name and Description
 
add(username, auth, type)

add a new account

 

 
get(id, type)

retrives the user object by user and type

 

returns the array of accounts

 
getByType(type)

 
getByUsername(username)

 
getByUsernameAndType(username, type)

 
getMeta(id, key)

 

wipes the accounts array and saves it

 
load()

loads the accounts array from the prefs object

 
remove(id)

 
save()

saves the accounts array to the prefs obj

 
setAll(accounts_array)

Set all users by passing in a hash.

 
setMeta(id, key, value)

 
update(id, acctobj)

Class Detail

SpazAccounts((Object))

This creates a new SpazAccounts object, and optionally associates it with an existing preferences object

Parameters:
(Object)
prefsObj An existing SpazPrefs object (optional)
Field Detail

prefskey

the key used inside the prefs object

Method Detail

{object} add(username, auth, type)

add a new account

Parameters:
{string} username
the username of the account
{string} auth
serialized authentication key, generated by SpazAuth.save()
{string} type
the type of account
Returns:
{object} the account object just added

{string} generateID()

Returns:
{string} returns the generated UUID

get(id, type)

retrives the user object by user and type

Parameters:
{string} id
the user id UUID
{string} type

{array} getAll()

returns the array of accounts

Returns:
{array} the accounts

{array} getByType(type)

Parameters:
{string} type
the type of accounts to retrieve
Returns:
{array} the array of matching accounts

{array} getByUsername(username)

Parameters:
{string} username
the username to search for
Returns:
{array} an array of matching accounts

{array} getByUsernameAndType(username, type)

Parameters:
{string} username
the username to search for
{string} type
the type to search for
Returns:
{array} an array of matching accounts

{String|Object|Array|Boolean|Number} getMeta(id, key)

Parameters:
{string} id
the user's UUID
{string} key
the key for the metadata entry
Returns:
{String|Object|Array|Boolean|Number} returns the set value, or null if user ID or meta entry is not found

initAccounts()

wipes the accounts array and saves it

load()

loads the accounts array from the prefs object

remove(id)

Parameters:
{string} id
the UUID of the account to delete

save()

saves the accounts array to the prefs obj

setAll(accounts_array)

Set all users by passing in a hash. overwrites all existing data!

Parameters:
{array} accounts_array
an array of account objects

{String|Object|Array|Boolean|Number} setMeta(id, key, value)

Parameters:
{string} id
the user's UUID
{string} key
the key for the metadata entry
{String|Object|Array|Boolean|Number} value
the value of the metadata entry
Returns:
{String|Object|Array|Boolean|Number} returns the set value, or null if user ID is not found

update(id, acctobj)

Parameters:
{string} id
the UUID to update
{object} acctobj
{string} acctobj.username Optional
a new username
{string} acctobj.password Optional
a new password
{string} acctobj.type Optional
a new account type
{object} acctobj.meta Optional
the hash of metadata; you should probably use SpazAccounts.setMeta() instead