Automatic login with the Ubiquiti NVR (tested on 3.7.3)

I was looking for a way for my Raspberry PI to automatically log into my Ubiquiti NVR and having found a few resources online all dealing with VB script launchers figured there has to be an easier way. I was wrong. But here is what I came up with.

I’m going to assume you know how to use SSH, nano (or vi or your favorite editor) and can search/type in a compressed javascript file.

SSH into the NVR and head on over to the /usr/lib/unifi-video/webapps/ROOT/static/js/(version.js) file – this will be a long named javascript file with the latest build. Note – this will change on each patch so get used to editing this until Ubiquiti figures out this is a needed feature. In my case, the file is called uv3.833f7b634e8027fc5fcb19f3b27e440690db4b43.min.js

Search for the /uv3/views/LoginView controller and edit the data to change the lines from:

username: this.$username.val(), password: this.$password.val()
to
username: "(your username)", password: "(your password)"

This will automatically provide a username/password to the controller on form submission. Now to get the controller to automatically log you in, look for the function nearby called didInsertElement and edit it from:
this.$().find("input")[0] && this.$().find("input")[0].focus()
to
this.$().find("input")[0] && this.$().find("input")[0].focus();this.doLogin();

Now when you browse to the login screen it will automatically log you in without the need for a VB script.

Naturally, it will always login with the given username/password so before any admin functions you need to perform you will need to swap out the changes and any patching will undo all of these changes.

Round three of my edit will include the ability to provide a different username/password based on the calling IP address so from my administrator machine or VPN tunnel I can access the admin features while reception will automatically login with a standard user account.

PS. The logout button now will also not do anything unless you redirect it elsewhere.