Show portion of UI based on flag during Login

In Login page, on click of login button i have a pop-up indicating that the Authentication is in progress. On completion of the authentication, want to remove the pop-up and load the next page.

To achieve the same, I have made some changes to dispatcher.lua where before the 'session_setup()' is called, the Login template is called again by setting a flag.

Attaching my code snippet.

In sysauth.htm

<%- if showpopup then %>
	<div id="loader-popup" >
		<br>Authentication in progress, please wait ...
		<br>
	</div>
<% end -%>
....

In dispatcher.lua => dispatch()

if user == nil and pass == nil then
	user = http.formvalue("luci_username")
	pass = http.formvalue("luci_password")

	if user and pass then
		local tmpl = require "luci.template"
		tmpl.render("sysauth", {
			showpopup = "In Progress"
		})
	end
end
sid, sdat = session_setup(user, pass, track)
.....

Currently, the template is rendered with an pop-up but on completion of authentication, the cookie is not being set and the template does not change, I am not sure why.
How can I change the currently loaded template?

Is there a possibility of showing/hiding the pop-up in loaded template without re-rendering template?