# האם יש דרך להאזין לאירוע כניסת משתמש באמצעות רכיב Theme

**URL:** <https://meta.discourse.org/t/is-there-any-way-to-listen-user-login-event-using-theme-component/170976>\
**Category:** Development\
**Created:** [23 בנובמבר,‏ 2020,‏ 4:30am UTC](https://meta.discourse.org/t/is-there-any-way-to-listen-user-login-event-using-theme-component/170976 "2020-11-23T04:30:14Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)\
**Post date:** [24 בדצמבר,‏ 2020,‏ 10:20pm UTC](https://meta.discourse.org/t/is-there-any-way-to-listen-user-login-event-using-theme-component/170976/15 "2020-12-24T22:20:31Z")

</div>

This looks good 👍

I tried it locally and didn’t see any problems. I made a few minor changes.

```xml
<script
  src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/5.4.1/bootbox.min.js"
  integrity="sha512-eoo3vw71DUo5NRvDXP/26LFXjSFE1n5GQ+jZJhHz+oOTR4Bwt7QBCjsgGvuVMQUMMMqeEvKrQrNEI4xQMXp3uA=="
  crossorigin="anonymous"
></script>

<script type="text/discourse-plugin" version="0.8">
  const user = api.getCurrentUser();
  if (!user || user.read_first_notification || user.enforcedSecondFactor) {
    return;
  }

  const bootboxTitle = `<div class="first-login-bootbox-title">You're a member. Welcome aboard!</div>`;
  const bootboxBody = `<div class="first-login-bootbox-body">Now you can: </br> <ol class="user-suggestions"><li><a href="/new-topic" target="_blank" >Ask a question or start a discussion</a></li> <li><a href="/my/preferences/tags" target="_blank">Set up your notification settings</a></li></ol></div>`;

  /* Adding new Method to header Widget which will call after displaying Welcome-popup*/
  api.reopenWidget("header", {
    closeFirstNotificationMask() {
      this.state.ringBackdrop = false;
      this.state.userVisible = !this.state.userVisible;
    }
  });

  /* Created new widget "welcome-popup", this widget will be render only when user login for the first time */
  api.createWidget("welcome-popup", {
    tagName: "div.welcome-popup",
    html(attrs) {
      //Calling closeFirstNotificationMask action method of header widget
      this.sendWidgetAction("closeFirstNotificationMask", attrs);

      bootbox.alert({
        title: bootboxTitle,
        message: bootboxBody
      });
    }
  });

  /* Below code will render "welcome-popup" widget after rendering "header-notifications" widget when User login first time*/
  api.decorateWidget("header-notifications:before", helper => {
    if (!helper.attrs.active && helper.attrs.ringBackdrop) {
      return helper.attach("welcome-popup", helper.attrs);
    }
  });
</script>

```

> [@Saurabh\_Khandelwal](#):
>
> we using Bootbox 5.4.1 version by including the below script in our theme component as currently Discourse not support the multi-parameter bootbox method. Is it Ok?

Yes, that’s OK. Discourse loads the bootbox version we use as a shim, so loading a different version in your theme component won’t change anything in core. The new version will only be used in your theme component. The only downside is that it adds one extra request and ~4kb to the initial page load.

---

_[View the full topic](https://meta.discourse.org/t/is-there-any-way-to-listen-user-login-event-using-theme-component/170976)._
