Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This operation generates an OTP code and sends it using SMS/Text to the users mobile number.

Code Block
languagejs
titleImplementation of POST /auth/sendsms
linenumberstrue
collapsetrue
try {
    context.agent.newToken(context.id,43,"sendsms");
    
    context.respond(201, 'SMS Sent', 'application/json','');
} catch(err) {
    if (! (err instanceof Java.type('java.lang.Throwable')))
        throw err;
        
    context.trace.trace("SendSMS failed", err);
    if (err instanceof Java.type('dk.itp.security.passticket.PTException')) {
        var response = {
            "code": err.getErrorCode(),
            "message": err.getErrorText()
        };
        
        if (!response.message)
            response.message = "Unknown error";
            
        context.respond(400, 'Send SMS Failed', 'application/json', JSON.stringify(response));    
    } else {
        throw err;
    }
}

...