Force initial password change in LuCI

Hello,

I work on a custom image from OpenWrt 23.03. I set default password at build time but I would like to force users to change password on first login.

I see this issue but it seems to be inactive: https://github.com/openwrt/openwrt/issues/7549

What I would like to do is to intercept the requested page to force displaying the Route password page in case the default password hasn't been changed.

As a first step, I found that this could be possible to do this in dispatcher.uc. I successfully force to displaying the password page with the following changes. Like what it's done for the login page I will redirect the requested page when the password has been changed.

		if (require_post_security(action) && !test_post_security(resolved.ctx.authtoken))
			return;

// **** NEW CODE ***
		if (is_default_password())
		{
			run_action(path, lang, menu, resolved, { type: "view", path: "system/password" });
			return;

		}
// **********************
		run_action(path, lang, menu, resolved, action);
	}
	catch (ex) {
		error500('Unhandled exception during request dispatching', ex);
	}

Is there a way to hide the menu to prevent the user from changing pages or just let the logout button?

thanks for any hint

1 Like