Guest user login using login-as-guest function

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:

function loginAsGuest() {{
        method: "frappe.core.doctype.user.user.login_as_guest",
        callback: function(response) {
            if (response.message) {
                window.location.href = response.message.location;

I have set guest_login == true in th file in get_context function as:

def get_context(context):
	context["guest_login"] = True

I have added the login-as-guest in the file:

	def login_as_guest():
		user = frappe.get_doc("User", "Guest")
		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