Have cursor in username field on LUCI login

Hi,
I followed this: Hide root user on LUCI login
To have an empty username field by default on the LUCI login page. But the cursor defaults to the password field. I would like to have it in the username field otherwise Keepass auto type gets confused.

Cheers

Edit: seems to be unnecessary with the bootstrap theme. Skip this post and see later posts.

Find your sysauth.htm file and change the highlighted line below to replace luci_password with luci_username

2 Likes

I found it in /usr/lib/lua/luci/view/sysauth.htm
cleared the cache rm /tmp/luci-modulecache/* and restarted uhttp /etc/init.d/uhttpd restart

But the cursor is still focused on the password.

Look in any theme subdirectories too.

find /usr/lib -name sysauth.htm

I'm using bootstrap, I think there is nothin that needs to be changed?

/usr/lib/lua/luci/view/themes/bootstrap/sysauth.htm

<%#
 Copyright 2021 Jo-Philipp Wich <jo@mein.io>
 Licensed to the public under the Apache License 2.0.
-%>

<%
        -- tell bootstrap's templates to not render header and footer
        blank_page = true
%>

<%+header%>

<section hidden>
        <form method="post" class="cbi-map">
                <div class="cbi-section">
                        <div class="cbi-section-node">
                                <div class="cbi-value">
                                        <label class="cbi-value-title" for="luci_username"><%:Username%></label>
                                        <div class="cbi-value-field">
                                                <input name="luci_username" type="text"<%=attr("value", duser)%>>
                                        </div>
                                </div>
                                <div class="cbi-value">
                                        <label class="cbi-value-title" for="luci_password"><%:Password%></label>
                                        <div class="cbi-value-field">
                                                <input name="luci_password" type="password">
                                        </div>
                                </div>
                        </div>
                </div>
        </form>

        <hr>

        <% if fuser then %>
        <div class="alert-message error">
                <%:Invalid username and/or password! Please try again.%>
        </div>
        <% end %>

        <button class="btn cbi-button-positive important"><%:Login%></button>
</section>

<div id="view">
        <div class="spinning"><%:Loading view…%></div>
        <script type="text/javascript">
                L.require('ui').then(function(ui) {
                        ui.instantiateView('bootstrap.sysauth');
                });
        </script>
</div>

<%+footer%>

How about changing this from type="password" to name="luci_username" in /www/luci-static/resources/view/bootstrap/sysauth.js

You are discovering I’m no expert in this area.

1 Like

Nice, that is confirmed working!