uba_otp_ns

@unitybase/uba~ uba_otp_ns

One time passwords. One-time-password generation and verification

Constructor

new uba_otp_ns()

Mixes In:
mStorage   

Extends

Members

attrs static

Attributes defined in metadata. This property not exist in real life and added just for help

entity: UBEntity

Reference to entity metadata

Methods

addNew(ctx) api

Create record with filled default values and return it to caller. Newly created record is not inserted to database. For inserting record to the database insert method should be called
Arguments:
  1. ctx (ubMethodParams)
Mixes In:
mStorage.addNew   

delete(ctx) api

Delete data
Arguments:
  1. ctx (ubMethodParams)
    Properties
    1. mParams.execParams.ID (number)  element ID to be deleted
Mixes In:
mStorage.delete   

insert(ctx) api

Insert new row to the entity.
Arguments:
  1. ctx (ubMethodParams)
    Properties
    1. mParams.execParams (Object|TubList)  Object keys is entity attributes names, key values is a value to be inserted
Mixes In:
mStorage.insert   

select(ctx) api

Read entity data
Arguments:
  1. ctx (ubMethodParams)
    Properties
    1. mParams (UBQL)  ORM query in UBQL format
Mixes In:
mStorage.select   

update(ctx) api

Update data
Arguments:
  1. ctx (ubMethodParams)
    Properties
    1. mParams.execParams (Object|TubList)  Object keys is entity attributes names, key values is a value to be inserted
      Properties
      1. ID (number)  element ID to be updated
Mixes In:
mStorage.update   

auth(otp, otpKind, fCheckUDataopt, checkDataopt, callopt)Boolean

Switch session to user from OTP or execute callback in session of user from OTP
Arguments:
  1. otp (string)
  2. otpKind (string)
  3. [fCheckUData] (function)  function for check OTP from uData
  4. [checkData] (Object)  value for check OTP from uData
  5. [call] (function)  This function will be called in user's session. If defined then restore original user session after call it.
Deprecated:
  • use authAndExecute instead

authAndExecute(otp, otpKind, callBack)Boolean

Check given otp, and in case it is correct run callback
Arguments:
  1. otp (string)
  2. otpKind (string)
  3. callBack (function)  This function will be called in user's session with uData parameter from otp if otp is correct.
Example
// generation otp
  var userID = 100000000122,
     uData = {size: {width: 100, height: 50}};
  var otp = uba_otp.generateOtp('EMail', userID, uData);
  // send this otp via EMail
  //............................
  // after receiving this otp
  var isOtpCorrect =  uba_otp.authAndExecute('EMail', otp, function(uData){
     var params = JSON.parse(uData);
     console.log('user ID is', Session.userID);//'user ID is 100000000122';
     console.log('width is', params.width);//'width is 100';
  }));