Running custom code on login to backoffice?
# help-with-umbraco
m
I need to run some custom JavaScript code when a user logs into the backoffice. I have seen how to add a new tab and I am going to use that method as a fall back but ideally I would rather not leave it up to the end user to click on that tab to run the code (the code is JavaScrpipt to place a marker on there computer to exclude them from the site analitics program). I do use "TheDashboard" add on so the normal page that shows when loged in has been replaced by that, unfortunatly they just confirmed that I can't easly make changes to that plugin without having to fork and write my own version. I should mention i am on v13 in case that makes a difference
j
If you register a JS controller in a package.manifest, then you can trigger stuff on the app.ready event like so:
Copy code
js
(function () {
    'use strict';

    function loader(eventsService) {
        // fired when a user is authenticated and logged in
        eventsService.on('app.ready', function () {
            // custom code
        });
    }

    angular.module('umbraco').run(loader);
})();
I have a more complete example of it at the bottom of this article: https://skrift.io/issues/an-overview-of-options-to-extend-the-umbraco-backoffice/
m
Thanks, based off your link and the section about injecting the skrift logo I think this will work real well, also so me how to inject my logo into the backoffice 🙂
15 Views