Hook for actions at login

Is there a hook or some other mechanism to take some actions when a user first logs in?

We have implemented a widget on the dashboard to take these actions now, but if the user does a direct link to another page besides the dashboard, the action is skipped. Is there a better way?

Ed

I think maybe required announcements are what you’re looking for? But that’ll make all users have to click through it (not just first login) and I don’t know if it actually redirects you back to the dashboard page or forwards you to the page you were trying to navigate to.

Unfortunately, that isn’t the action I’m looking for. We want an action to be taken in the background when the user logs in – no user interaction required.

OK I’m now reading that as ‘when a user first logs in’ as opposed to my initial read which was ‘the first time a user logs in’.

You can use an initializer here for that. These run when the dashboard boots up. This is how you add favorite paths to the dashboard, during initialization you add favorite paths.

In that same manner - you can do something here at this time.

So … that is closer to what I’m looking for … and may be a better solution than the widget we’re currently using.
It doesn’t address the case where a user bypasses the dashboard using a direct link to another page. I’ve done this many times when reviving an old session in the morning … I refresh the page, it takes me to authenticate, then puts me right back where I was, and the dashboard app never gets activated. Is there an initializer for the OOD platform itself that is run when ANY page is activated?

I guess you could write an initializer that adds something to the base controller like so

Rails.application.config.after_initialize do
  class ApplicationController < ActionController::Base
    before_action :my_special_thing

    def my_special_thing
      # add your logic here, though you should note that it'll run 
      # on _every single page request_.
    end
  end
end

Hmmm … that looks promising … I’ll take a look at it! Where in the OOD source would this need to be placed?

Yes … I understand that it will run on every page load … that means it is on us to make it as lean as possible to see if something needs to be done.

Thanks!

It’s not in the source code - you add it as an initializer in /etc/ood/config/apps/dashboard/initializers - or a similar directory, I’m pulling that directory from memory so it could be off a bit.

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