You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: web_login.go
    path of file: ./repos/arozos/src/mod/auth/ldap
    
    the code of the file until where you have to start completion: package ldap

import (
	"encoding/json"
	"log"
	"net/http"
	"strconv"

	"imuslab.com/arozos/mod/utils"
)

// LOGIN related function
// functions basically same as arozos's original function
func (ldap *ldapHandler) HandleLoginPage(w http.ResponseWriter, r *http.Request) {
	checkLDAPenabled := ldap.readSingleConfig("enabled")
	if checkLDAPenabled == "false" {
		utils.SendTextResponse(w, "LDAP not enabled.")
		return
	}
	//load the template from file and inject necessary variables
	red, _ := utils.GetPara(r, "redirect")

	//Append the redirection addr into the template
	imgsrc := "./web/" + ldap.iconSystem
	if !utils.FileExists(imgsrc) {
		imgsrc = "./web/img/public/auth_icon.png"
	}
	imageBase64, _ := utils.LoadImageAsBase64(imgsrc)
	parsedPage, err := utils.Templateload("web/login.system", map[string]string{
		"redirection_addr": red,
		"usercount":
    
func (ldap *ldapHandler) HandleSetPassword(w http.ResponseWriter, r *http.Request) {
	checkLDAPenabled := ldap.readSingleConfig("enabled")
	if checkLDAPenabled == "false" {
		utils.SendTextResponse(w, "LDAP not enabled.")
		return
	}
	//get paramters from request
	username, err := utils.PostPara(r, "username")
	if err != nil {
		utils.SendErrorResponse(w, err.Error())
		return
	}
	password, err := utils.PostPara(r, "password")
	if err != nil {
		utils.SendErrorResponse(w, err.Error())
		return
	}
	authkey, err := utils.PostPara(r, "authkey")
	if err != nil {
		utils.SendErrorResponse(w, err.Error())
		return
	}

	//check if the input key matches the database's username
	isValid := ldap.syncdb.Read(authkey) == username
	ldap.syncdb.Delete(authkey) // remove the key, aka key is one time use only
	//if db data match the username, proceed
	if isValid {
		//if not exists
		if !ldap.ag.UserExists(username) {
			//get the user from ldap server
			ldapUser, err := ldap.ldapreader.GetUser(username)
			if err != nil {
				utils.SendErrorResponse(w, err.Error())
				return
			}
			//convert the ldap usergroup to arozos usergroup
			convertedInfo := ldap.convertGroup(ldapUser)
			//create user account and login
			ldap.ag.CreateUserAccount(username, password, convertedInfo.EquivGroup)
			ldap.ag.Logger.LogAuth(r, true)
			ldap.ag.LoginUserByRequest(w, r, username, false)
			utils.SendOK(w)
			return
		} else {
			//if exist then return error
			utils.SendErrorResponse(w, "User exists, please contact the system administrator if you believe this is an error.")
			return
		}
	} else {
		utils.SendErrorResponse(w, "Improper key detected")
		log.Println(r.RemoteAddr + " attempted to use invaild key to create new user but failed")
		return
	}
}