I have the Login as Guest button in the login.html file:
<button class="btn btn-primary btn-block" onclick="loginAsGuest()">{{ _("Login as guest") }}</button>
and added this js code to the same file which handles the login-as-guest action:
<script>
function loginAsGuest() {
frappe.call({
method: "frappe.core.doctype.user.user.login_as_guest",
callback: function(response) {
if (response.message) {
window.location.href = response.message.location;
}
}
});
}
</script>
I have set guest_login == true in th login.py file in get_context function as:
def get_context(context):
context["guest_login"] = True
I have added the login-as-guest in the user.py file:
@frappe.whitelist(allow_guest=True)
def login_as_guest():
user = frappe.get_doc("User", "Guest")
frappe.local.login_manager.login_as(user.name)
frappe.local.response["type"] = "redirect"
frappe.local.response["location"] = "/"
but the login-as-guest action still checks the username and password whereas the login-as-guest suppose to login without a login username and password