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

Mixes In:

# new uba_otp_ns ()

Members

# attrs : ubaOtpAttrs static

Attributes defined in metadata. Property does not exist in real life and added for IDE

# entity : UBEntity instance

Reference to entity metadata

Methods

# addNew (ctxubMethodParams) instance

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:

# delete (ctxubMethodParams) instance

Delete record by ID

Arguments:

# insert (ctxubMethodParams) instance

New record insertion

Arguments:

# select (ctxubMethodParams) instance

ORM query for read records

Arguments:

# update (ctxubMethodParams) instance

Update existed record

Arguments:
  • ctx: ubMethodParams
    • mParamsobject

      Update method parameters

    • fieldListarray.<string>

      Optional attributes names. Values of this attributes will be returned in result. Additional DB query is required to return values, so if caller do not need it better to not pass a fieldList to update

# auth (otpstring, otpKindstring, fCheckUDataoptfunction, checkDataoptobject, calloptfunction) → boolean instance deprecated

use authAndExecute instead

Switch session to user from OTP (SMS or EMail) or execute callback in session of user from OTP. For TOTP use verifyTotp function.

Arguments:
  • otp: string
  • otpKind: string
  • fCheckUData: function

    function for check OTP from uData

  • checkData: object

    value for check OTP from uData

  • call: function

    If defined then this function will be called in user's session and restore original user session after call

# authAndExecute (otpstring, otpKindstring, callBackfunction) → boolean instance

Check given otp, and in case it is correct run callback

Return:

Is otp correct

Arguments:
  • otp: string
  • otpKind: string
  • callBack: function

    This function will be called in user's session with uData parameter from otp if otp is correct.

  
      // 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';
}))
  

# verifyTotp (totpValuestring, userIDoptnumber) → boolean instance

Verify TOTP for currently logged-in user

Arguments:
  • totpValue: string

    TOTP value entered by user (6 digits string)

  • userID: number

    optional user ID to verify TOTP for. By default - Session.userID