public async Task <IActionResult> AuthOnPublishM5([FromBody] AuthOnPublishM5Payload request) { var result = await AuthorizeOnPublishM5(request); if (result != null && result is OkAuthOnPublishM5Result item) { return(Ok(new { Result = "ok", Modifiers = new { item.Topic } })); } return(result.GeneratePublicResult()); }
/// <summary> /// This method is called when client is trying to publish a message to specific topic in MQTT v5. You can authorize client and accept or reject this request. /// To accept the client to publish the message return complex <see cref="OkAuthOnPublishM5Result"/> to rewrite the topic and the payload or simple <see cref="OkResult"/> /// To ignore authorization return <see cref="NextResult"/> /// To reject the client return <see cref="ErrorResult"/> /// For more information <see cref="https://docs.vernemq.com/plugin-development/publishflow#auth_on_publish-and-auth_on_publish_m5"/> /// </summary> /// <param name="authOnRegisterPayload">publish message information</param> /// <returns>return value must be one of <see cref="OkResult"/> or <see cref="OkAuthOnPublishM5Result"/> or <see cref="NextResult"/> or <see cref="ErrorResult"/> </returns> protected virtual async Task <HookResult> AuthorizeOnPublishM5(AuthOnPublishM5Payload authOnRegisterPayload) { return(new OkResult()); }