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?
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
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.