Global

Methods

createUser(user) → {userMeta}

Source:

Create a new user on Firebase with borrower creation on Loandisk

Example
createUser({
  uid: "hk_wx5555556",
  branchID: 8895,
  country: "HK",
  idNumber: "WX555555(6)",
  passwordHash: "47fcd521684caf1ffb506e7097747b76e086a30f6f4c1968845fea8cc01ea375",
});
Parameters:
Name Type Description
user object

User object

Properties
Name Type Description
uid string

Firebase User ID, e.g. hk_wx5555556.

branchID number

Branch ID of target branch where the user belongs to.

country string

Country of employment, e.g. HK.

idNumber string

ID number at country of employment, e.g. WX555555(6).

passwordHash string

Hashed password.

Requires:
Returns:

User’s user meta.

Type
userMeta

generateUserToken(user) → {string}

Source:

Generate Firebase user token of a user

Example
generateUserToken({
  uid: "hk_wx5555556",
});
Parameters:
Name Type Description
user object

User object

Properties
Name Type Description
uid string

Firebase User ID, e.g. hk_wx5555556.

Requires:
Returns:

User’s JSON web token.

Type
string

getUser(user) → {userMeta}

Source:

Get a user’s user meta from Firebase

Example
getUser({
  uid: "hk_wx5555556",
});
Parameters:
Name Type Description
user object

User object

Properties
Name Type Description
uid string

Firebase User ID, e.g. hk_wx5555556.

Requires:
Returns:

User’s user meta.

Type
userMeta

getVersionCode() → {number}

Source:

Get minimum application version code from Firebase

Example
getVersionCode({})
Requires:
Returns:

App version code.

Type
number

isPasswordResettable(user) → {boolean}

Source:

Check if password is resettable

Example
isPasswordResettable({
  uid: "hk_wx5555556",
});
Parameters:
Name Type Description
user object

User object

Properties
Name Type Description
uid string

Firebase User ID, e.g. hk_wx5555556.

Requires:
Returns:

Whether is password is now resettable. True if Good Financial team has set passwordResettable to true, False if passwordResettable has remain untouched or the field doesn’t exists.

Type
boolean

isUser(user) → {string|boolean}

Source:

Check if a Firebase ID has been assigned before

Example
isUser({
  uid: "hk_wx5555556",
});
Parameters:
Name Type Description
user object

User object

Properties
Name Type Description
uid string

Firebase User ID, e.g. hk_wx5555556.

Requires:
Returns:

Returns boolean, otherwise returns 'legacy' if user is a legacy user

Type
string | boolean

logInUser(user) → {string|boolean}

Source:

Log in a user

Example
logInUser({
  uid: "hk_wx5555556",
  passwordHash: "47fcd521684caf1ffb506e7097747b76e086a30f6f4c1968845fea8cc01ea375",
});
Parameters:
Name Type Description
user object

User object

Properties
Name Type Description
uid string

Firebase User ID, e.g. hk_wx5555556.

passwordHash string

Hashed password.

Requires:
Returns:

User’s JSON web token if successfully validated, otherwise returns false.

Type
string | boolean

resetFailCount(user) → {boolean}

Source:

Reset a user’s fail count

Example
// Reset fail count
resetFailCount({
  uid: "hk_wx5555556",
});
Parameters:
Name Type Description
user object

User object

Properties
Name Type Description
uid string

Firebase User ID, e.g. hk_wx5555556.

Requires:
Returns:

Returns true on success.

Type
boolean

testControl(data) → {boolean}

Source:

Reset all test accounts

Examples
testControl({
  command: "resetData"
});
testControl({
  command: "unlockReloanAppointment",
  params: {
    uid: "hk_wx1111114",
    appointmentType: "phone"
  }
});
Parameters:
Name Type Description
data object

The data object attached to the request

Properties
Name Type Description
command string

The command to execute

params object

Object with named parameters for the command

Requires:
Returns:

Returns true.

Type
boolean

updateUser(user) → {userMeta}

Source:

Update a user’s user meta on Firebase

Example
updateUser({
  uid: "hk_wx5555556",
  passwordHash: "47fcd521684caf1ffb506e7097747b76e086a30f6f4c1968845fea8cc01ea375",
});
Parameters:
Name Type Description
user object

User object

Properties
Name Type Description
uid string

Firebase User ID, e.g. hk_wx5555556.

passwordHash string

Hashed password.

Requires:
Returns:

User’s user meta.

Type
userMeta

validateUser(user) → {string|boolean}

Source:

Validate a user’s log in credentials

Example
validateUser({
  uid: "hk_wx5555556",
  passwordHash: "47fcd521684caf1ffb506e7097747b76e086a30f6f4c1968845fea8cc01ea375"
});
Parameters:
Name Type Description
user object

User object

Properties
Name Type Description
uid string

Firebase User ID, e.g. hk_wx5555556.

passwordHash string

Hashed password.

Requires:
Returns:

User’s Firebase UID if successfully validated, otherwise returns false.

Type
string | boolean

Type Definitions

userMeta

Source:
Properties:
Name Type Description
borrowerID number

Loandisk borrower ID

branchID number

Loandisk branch ID

country string

Country of employment, e.g. HK.

idNumber string

ID number at country of employment, e.g. WX555555(6).

passwordHash string

Hashed password.

User’s user meta

Type:
  • Object
Example
{
  "borrowerID": 847714,
  "branchID": 8895,
  "country": "HK",
  "idNumber": "WX555555(6)",
  "passwordHash": "GoodCashIsTheBest",
}