# Everyone can join with meeting as a HOST

**URL:** <https://devforum.zoom.us/t/everyone-can-join-with-meeting-as-a-host/46717>\
**Category:** Web\
**Created:** [March 27, 2021, 1:36am UTC](https://devforum.zoom.us/t/everyone-can-join-with-meeting-as-a-host/46717 "2021-03-27T01:36:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![digix.sameera](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/digix.sameera/32/23747_2.png) [@digix.sameera](https://devforum.zoom.us/u/digix.sameera)\
**Post date:** [March 27, 2021, 1:36am UTC](https://devforum.zoom.us/t/everyone-can-join-with-meeting-as-a-host/46717/1 "2021-03-27T01:36:44Z")

</div>

I m using web sdk. and every student can join as a HOST . LOL scenario.

Please help me to resolve this case. here is JS script code

```
<script>
window.addEventListener('DOMContentLoaded', function (event) {
    console.log('DOM fully loaded and parsed');
    websdkready();
});

function websdkready() {
    var testTool = window.testTool;
    // get meeting args from url
    var tmpArgs = testTool.parseQuery();
    console.log(tmpArgs)

    var meetingConfig = {
        apiKey: "{{$apiKey}}",
        meetingNumber: "{{$zoomMeetingId}}",
        userName: "{{$userName}}",
        passWord: "{{$meetingPassword}}",
        leaveUrl: "/index.html",
        role: "{{$meetingRole}}",
        userEmail: "{{$userEmail}}",
        lang: "{{$meetingLang}}",
        signature: "{{$signature}}",
        china: "{{$meetingChina}}",
    };

    // a tool use debug mobile device
    if (testTool.isMobileDevice()) {
        vConsole = new beginJoinVConsole();
    }

    if (meetingConfig.china)
        ZoomMtg.setZoomJSLib("https://jssdk.zoomus.cn/1.9.1/lib", "/av"); // china cdn option
    ZoomMtg.preLoadWasm();
    ZoomMtg.prepareJssdk();

    function beginJoin(signature) {
        ZoomMtg.init({
            leaveUrl: meetingConfig.leaveUrl,
            webEndpoint: meetingConfig.webEndpoint,
            disableInvite: true,
            disableCallOut: true,
            debug: true,
            isSupportAV: true,
            isSupportChat: false,
            meetingInfo: [],

            success: function () {
                ZoomMtg.i18n.load(meetingConfig.lang);
                ZoomMtg.i18n.reload(meetingConfig.lang);

                console.log(meetingConfig);

                ZoomMtg.join({
                    meetingNumber: meetingConfig.meetingNumber,
                    userName: meetingConfig.userName,
                    userEmail: meetingConfig.userEmail,
                    signature: signature,
                    apiKey: meetingConfig.apiKey,
                    passWord: meetingConfig.passWord,

                    success: function (res) {
                        console.log("join meeting success");
                        console.log(res);
                    },
                    error: function (res) {
                        console.log(res);
                    },
                });
            },
            error: function (res) {
                console.log(res);
            },
        });
        ZoomMtg.inMeetingServiceListener('onUserJoin', function (data) {
            console.log("ON USER JOIN");
            console.log('inMeetingServiceListener onUserJoin', data);

            var userId = data.userId;
            var userEmail = data.userName;
            var isHost = data.isHost;
            var zoomMeetingId = "{{$zoomMeetingId}}";

            if (!isHost) {
                var isValidAuthorizedUser = checkAuthorizedUser(userEmail); //Default : True
                var isValidCourseEnrollment = checkValidEnrollment(zoomMeetingId, userEmail); //Default : True
                var hasUnpaidInvoices = checkHasUnpaidInvoices(userEmail); //Default : False

                console.log("has Unpaid Invoices : " + hasUnpaidInvoices);
                console.log("Is Valid Course Enrollment : " + isValidCourseEnrollment);
                console.log("Is Valid Authorized User : " + isValidAuthorizedUser)
                console.log("Condition :" + (isValidAuthorizedUser === "false" || isValidCourseEnrollment === "false" || hasUnpaidInvoices === "true"));

                if (isValidAuthorizedUser === "false" || isValidCourseEnrollment === "false" || hasUnpaidInvoices === "true") {

                    console.log("Removed Participant");
                    //Remove Participant User
                    ZoomMtg.expel({
                        userId: userId
                    });
                }
            }

        });

        // Check Authorization of User
        function checkAuthorizedUser(userEmail) {

            var isAuthorizedUser = "";

            $.ajax({
                type: "GET",
                async: false,
                url: "{{ url('meeting/web/checkauthorizeduser') }}/",
                data: {
                    'userEmail': userEmail,
                    '_token': '{{csrf_token()}}',
                },
                dataType: 'HTML',
                success: function (response) {
                    isAuthorizedUser = response;

                }
            });

            return isAuthorizedUser;
        }

        // Check Validation of Enrollment
        function checkValidEnrollment(zoomMeetingId, userEmail) {

            var isValidEnrollment = "";

            $.ajax({
                type: "GET",
                async: false,
                url: "{{ url('meeting/web/checkvalidcourseenrollment') }}/",
                data: {
                    'zoomMeetingId': zoomMeetingId,
                    'userEmail': userEmail,
                    '_token': '{{csrf_token()}}',
                },
                dataType: 'HTML',
                success: function (response) {
                    isValidEnrollment = response;
                }
            });

            return isValidEnrollment;
        }

        //Get Unpaid Invoices
        function checkHasUnpaidInvoices(userEmail) {

            var isEmptyUnpaidInvoices = "";

            $.ajax({
                type: "GET",
                async: false,
                url: "{{ url('meeting/web/hasunapidinvoices') }}/",
                data: {
                    'userEmail': userEmail,
                    '_token': '{{csrf_token()}}',
                },
                dataType: 'HTML',
                success: function (response) {
                    isEmptyUnpaidInvoices = response;

                }
            });

            return isEmptyUnpaidInvoices;
        }

    }

    beginJoin(meetingConfig.signature);

};

```

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [March 29, 2021, 5:58pm UTC](https://devforum.zoom.us/t/everyone-can-join-with-meeting-as-a-host/46717/2 "2021-03-29T17:58:13Z")

</div>

Hey @digix.sameera ,

When generating the Web SDK signature, pass in 1 for host, and 0 for participant.

> **[Generate Signature - Build an App - Web - Client SDKs - Zoom Software...](https://marketplace.zoom.us/docs/sdk/native-sdks/web/build/signature)**
>
> Generate Signature
> 
> Each request to start or join a meeting / webinar must be verified by an encrypted signature authorizing each user to enter. A signa...

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![anweshan](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/anweshan/32/26346_2.png) [@anweshan](https://devforum.zoom.us/u/anweshan)\
**Post date:** [April 25, 2021, 6:57pm UTC](https://devforum.zoom.us/t/everyone-can-join-with-meeting-as-a-host/46717/3 "2021-04-25T18:57:51Z")

</div>

```php
/** 
 * @param string $api_key The publicly available key people may know.
 * @param string $api_secret The secret NO ONE SHOULD KNOW
 * @param integer $role The role of the user for whom the meeting is generated.
 * @param integer $meeting_number The "MEETING ID" to join.
 * @return string Should return a signature.
 */
function(string $api_key, string $api_secret, int $role = 0, int $meeting_number){
   // Setting to UTC for time() to be in UTC. However this is purely optional
  // See https://www.php.net/manual/en/function.time.php#100220
   // date_default_timezone_set("UTC");
    $time = time() * 1000 - 30000; //time in milliseconds (or close enough)
    $data = base64_encode($api_key . $meeting_number . $time . $role);
    $hash = base64_encode(hash_hmac('sha256', $data, $api_secret, true));
   // Generates a signature
    $sig = implode(".",[$api_key, $meeting_number, $time, $role, $hash]);
    // Return a base64 encoded, url-safe signature.
    return rtrim(strtr(base64_encode($sig), '+/', '-_'), '=');

```

If you have a application, where you can determine a user to be the “HOST” or want a user to be a “HOST” you can pass **1** in their behalf through a XHR Request, **0** otherwise.

#### Additional Information

If you just has a single page application, you can always take help of “Heroku”.

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/zoom/websdk-sample-signature-node.js)

Thanks,  
Anweshan 😃

---

<div class="post-metadata">

**Author:** ![will.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.zoom/32/14417_2.png) [@will.zoom](https://devforum.zoom.us/u/will.zoom)\
**Post date:** [April 26, 2021, 7:21pm UTC](https://devforum.zoom.us/t/everyone-can-join-with-meeting-as-a-host/46717/4 "2021-04-26T19:21:46Z")

</div>

Thanks for sharing this, @anweshan ! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [May 27, 2021, 5:21am UTC](https://devforum.zoom.us/t/everyone-can-join-with-meeting-as-a-host/46717/5 "2021-05-27T05:21:49Z")

</div>

Closed on May 27, 2021, 5:21am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
