Skip to main content

OTP API Reference

Module Information

Service Files:

  • Private: service/otp.js
  • Public: service/private/otp.js

Available Services: 3 Documented Services: 3


otp.set_password

Set a new password for a user after verifying a one-time password code. Verifies the OTP code and secret against the user identified by uid via the internal _verify helper (which also validates socket binding). If verification succeeds, updates the password, signs in the user, deletes the used secret, and returns the session result. Returns an error object if the OTP code is wrong.

PropertyValue
ScopeHub (requires hub context)
PermissionAnonymous (0)

Endpoint:

https://hostname/-/svc/otp.set_password

Parameters

ParameterTypeRequiredDefaultDescription
uidstringYes--
codestringYes--
secretstringYes--
passwordstringYes--
socket_idstringYes--

Returns

FieldTypeDescription
typeany-
descriptionany-
propertiesany-

Possible Errors

Error CodeHTTP StatusDescription
no-socket-WebSocket socket_id is not bound to the current session
no-user-No user found for the provided uid
wrong-otp-Wrong otp
INTERNAL_ERROR-Failed to update password or create session

otp.verify

Verify an OTP code for the given email address. Validates that the WebSocket socket_id is bound to the current session, checks that the user exists, and verifies the code against the stored secret via stored procedure secret_check. Returns the OTP record with the user ID on success, or an error status object on failure.

PropertyValue
ScopeHub (requires hub context)
PermissionAnonymous (0)

Endpoint:

https://hostname/-/svc/otp.verify

Parameters

ParameterTypeRequiredDefaultDescription
emailstringYes--
codestringYes--
secretstringYes--
socket_idstringYes--

Returns

FieldTypeDescription
typeany-
descriptionany-
propertiesany-

Possible Errors

Error CodeHTTP StatusDescription
no-socket-WebSocket socket_id is not bound to the current session
no-user-No user found for the provided email address
wrong-code-OTP code does not match the stored secret entry

otp.send

Send an OTP code to the user identified by email. Validates socket binding, checks the user exists, generates a secret and code via stored procedure secret_create (or otp_create if method is otp), then sends the code to the user email using the OTP email template. Returns the secret and user info for use in subsequent verify or set_password calls. The sent field indicates whether the email was delivered successfully.

PropertyValue
ScopeHub (requires hub context)
PermissionAnonymous (0)

Endpoint:

https://hostname/-/svc/otp.send

Parameters

ParameterTypeRequiredDefaultDescription
emailstringYes--
socket_idstringYes--
methodstringNo--

Returns

FieldTypeDescription
typeany-
descriptionany-
propertiesany-

Possible Errors

Error CodeHTTP StatusDescription
INVALID_SOCKET-WebSocket socket_id is not bound to the current session
no-user-No user account found for the provided email address
INTERNAL_ERROR-Failed to generate secret or send OTP email

  • ACL System - Permission model
  • Service Routing - URL patterns
  • Error Handling - Error codes