# האם יש דרך להאזין לאירוע כניסת משתמש באמצעות רכיב 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:** 3

<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,‏ 8:28am UTC](https://meta.discourse.org/t/is-there-any-way-to-listen-user-login-event-using-theme-component/170976/3 "2020-11-24T08:28:16Z")

</div>

Hey @Saurabh_Khandelwal 👋

> [@Saurabh\_Khandelwal](#):
>
> I have tried to override the login action

I would advise against doing it this way; login is one of the most critical actions, and any overrides to that action will be fragile and prone to breaking if we make any changes in the area in core.

> [@Saurabh\_Khandelwal](#):
>
> My requirement is Popup box should be displayed after redirecting to the Home page after successful login

If you recall, when you first signed up on this site, you saw something like this.

 ![first page view after login](https://global.discourse-cdn.com/meta/original/3X/5/5/558c483ef5cf07cc21fdc06b13a0f4fb5460be24.png)

The conditions [we use](https://github.com/discourse/discourse/blob/530d9ab07168b425235528f05da090751d31ac1a/app/assets/javascripts/discourse/app/widgets/header.js#L84-L111) to check for this are

```javascript
!user.read_first_notification && !user.enforcedSecondFactor

```

So, if you use the same conditions in an initializer, you’ll be able to render a Bootbox on the user’s very first-page view after login.

You can try something like this in your theme component.

```javascript
import { withPluginApi } from "discourse/lib/plugin-api";
import bootbox from "bootbox";

export default {
  name: "first-login-bootbox",
  initialize() {
    withPluginApi("0.8", api => {
      const user = api.getCurrentUser();
      if (!user) return;

      if (!user.read_first_notification && !user.enforcedSecondFactor) {
        const text = `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor`;
        bootbox.alert(text);
      }
    });
  }
};

```

and that will give you something like this

 ![first page view after login with bootbox](https://global.discourse-cdn.com/meta/original/3X/a/e/ae79d789188d000be1cac390e3977600d2780595.png)

You can use HTML in the text of the bootbox if needed. Once the user dismisses the bootbox and clicks on the circled avatar, they’ll never see the bootbox again.

Please note that bootboxes are meant for simple dialogs/confirmations. If you need something a little bit more complicated than that, then you’re probably better of using a modal with `showModal()`

---

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