func (h *AuthHandler) Login(email, password string) (User, string) { term.Write("Login user email"+email, term.Debug) term.Write(Config.UserName, term.Debug) bytes, err := client.Go("ignore", "com.duosoftware.auth", "users").GetOne().ByUniqueKey(email).Ok() var user User if err == "" { if bytes != nil { var uList User err := json.Unmarshal(bytes, &uList) if err == nil { if uList.Password == common.GetHash(password) && strings.ToLower(uList.EmailAddress) == strings.ToLower(email) { return uList, "" } else { term.Write("password incorrect", term.Error) } } else { if err != nil { term.Write("Login user Error "+err.Error(), term.Error) } } } } else { term.Write("Login user Error "+err, term.Error) } return user, "Error Validating user" }
func GetSession(key, Domain string) (AuthCertificate, string) { bytes, err := client.Go(key, "s.duosoftware.auth", "sessions").GetOne().ByUniqueKey(key).Ok() term.Write("GetSession For SecurityToken "+key, term.Debug) //term.Write("GetSession For SecurityToken "+string(bytes), term.Debug) var c AuthCertificate if err == "" { if bytes != nil { var uList AuthCertificate err := json.Unmarshal(bytes, &uList) if err == nil { if Domain == "Nil" { return uList, "" } else { if strings.ToLower(uList.Domain) != strings.ToLower(Domain) { uList.Domain = strings.ToLower(Domain) uList.SecurityToken = common.GetGUID() AddSession(uList) return uList, "" } else { return uList, "" } } } else { term.Write("GetSession Error "+err.Error(), term.Error) } } } else { term.Write("GetSession Error "+err, term.Error) } term.Write("GetSession No Session for SecurityToken "+key, term.Debug) return c, "Error Session Not Found" }
func (h *AuthHandler) AutherizeApp(Code, ApplicationID, AppSecret, UserID string) (bool, string) { bytes, err := client.Go("ignore", "com.duosoftware.auth", "authcode").GetOne().ByUniqueKey(Code).Ok() term.Write("AutherizeApp For ApplicationID "+ApplicationID+" Code "+Code+" Secret "+AppSecret+" Err "+err, term.Debug) var uList AuthCode err1 := json.Unmarshal(bytes, &uList) term.Write(string(bytes[:]), term.Debug) if err1 != nil { var appH applib.Apphanler application, err := appH.Get(ApplicationID, "ignorelib") if err == "" { if application.SecretKey == AppSecret && uList.UserID == UserID && Code == uList.Code { var appAth AppAutherize appAth.AppliccatioID = ApplicationID appAth.AutherizeKey = ApplicationID + "-" + UserID appAth.Name = application.Name client.Go("ignore", "com.duosoftware.auth", "atherized").StoreObject().WithKeyField("AutherizeKey").AndStoreOne(appAth).Ok() return true, "" } } else { return false, err } } else { return false, "Code invalid" } return false, "process error" }
func (h *AuthHandler) UserActivation(token string) bool { //respond := "" //check user from db bytes, err := client.Go("ignore", "com.duosoftware.com", "activation").GetOne().ByUniqueKey(token).Ok() if err == "" { var uList ActivationEmail err := json.Unmarshal(bytes, &uList) if err == nil || bytes == nil { //new user if err != nil { term.Write("Token Not Found", term.Debug) return false } else { //uList[0].GUUserID var u User var inputParams map[string]string inputParams = make(map[string]string) inputParams["email"] = u.EmailAddress inputParams["name"] = u.Name //Change activation status to true and save term.Write("Activate User "+u.Name+" Update User "+u.UserID, term.Debug) email.Send("ignore", "com.duosoftware.auth", "email", "user_activated", inputParams, u.EmailAddress) return true } } } else { term.Write("Activation Fail ", term.Debug) return false } return false }
func (h *TenantHandler) CreateTenant(t Tenant, user session.AuthCertificate, update bool) Tenant { term.Write("CreateTenant saving user "+t.Name, term.Debug) //client.c bytes, err := client.Go("ignore", "com.duosoftware.tenant", "tenants").GetOne().ByUniqueKey(t.TenantID).Ok() if err == "" { var uList Tenant err := json.Unmarshal(bytes, &uList) if err != nil { if t.TenantID == "" { t.TenantID = common.GetGUID() term.Write("Auto Gen TID "+t.TenantID+" New Tenant "+t.Name, term.Debug) } term.Write("Save Tenant saving Tenant "+t.Name+" New Tenant "+t.Name, term.Debug) var inputParams map[string]string inputParams = make(map[string]string) inputParams["email"] = user.Email inputParams["name"] = user.Name inputParams["tenantID"] = t.TenantID inputParams["tenantName"] = t.Name h.AddUsersToTenant(t.TenantID, t.Name, user.UserID, "admin") email.Send("ignore", "com.duosoftware.auth", "tenant", "tenant_creation", inputParams, user.Email) client.Go("ignore", "com.duosoftware.tenant", "tenants").StoreObject().WithKeyField("TenantID").AndStoreOne(t).Ok() } else { if update { term.Write("SaveUser saving Tenant "+t.TenantID+" Update user "+user.UserID, term.Debug) client.Go("ignore", "com.duosoftware.tenant", "tenants").StoreObject().WithKeyField("TenantID").AndStoreOne(t).Ok() } } } else { term.Write("SaveUser saving Tenant fetech Error #"+err, term.Error) } return t }
func (h *TenantHandler) AddTenantForUsers(Tenant TenantMinimum, UserID string) UserTenants { bytes, err := client.Go("ignore", "com.duosoftware.tenant", "userstenantmappings").GetOne().ByUniqueKey(UserID).Ok() var t UserTenants //t.UserID if err == "" { err := json.Unmarshal(bytes, &t) if err != nil { term.Write("No Users yet assigied "+UserID, term.Debug) t = UserTenants{UserID, []TenantMinimum{}} t.UserID = UserID } else { for _, element := range t.TenantIDs { if element.TenantID == Tenant.TenantID { return t } } } t.TenantIDs = append(t.TenantIDs, Tenant) client.Go("ignore", "com.duosoftware.tenant", "userstenantmappings").StoreObject().WithKeyField("UserID").AndStoreOne(t).Ok() term.Write("Saved Tenant users"+UserID, term.Debug) return t } else { return t } }
func (h *TenantHandler) AddUsersToTenant(TenantID, Name string, users, SecurityLevel string) TenantUsers { bytes, err := client.Go("ignore", "com.duosoftware.tenant", "users").GetOne().ByUniqueKey(TenantID).Ok() var t TenantUsers if err == "" { err := json.Unmarshal(bytes, &t) if err != nil { term.Write("No Users yet assigied "+t.TenantID, term.Debug) //t=TenantUsers{} t = TenantUsers{TenantID, []string{}} t.TenantID = TenantID } else { for _, element := range t.Users { if element == users { return t } } } h.AddTenantForUsers(TenantMinimum{TenantID, Name}, users) t.Users = append(t.Users, users) var Activ TenantAutherized Activ = TenantAutherized{} id := common.GetHash(users + "-" + TenantID) Activ.Autherized = true Activ.ID = id Activ.TenantID = TenantID Activ.SecurityLevel = SecurityLevel Activ.UserID = users client.Go("ignore", "com.duosoftware.tenant", "authorized").StoreObject().WithKeyField("ID").AndStoreOne(Activ).Ok() client.Go("ignore", "com.duosoftware.tenant", "users").StoreObject().WithKeyField("TenantID").AndStoreOne(t).Ok() term.Write("Saved Tenant users"+t.TenantID, term.Debug) return t } else { return t } }
func runRestFul() { gorest.RegisterService(new(authlib.Auth)) gorest.RegisterService(new(authlib.TenantSvc)) gorest.RegisterService(new(pog.POGSvc)) gorest.RegisterService(new(applib.AppSvc)) gorest.RegisterService(new(config.ConfigSvc)) gorest.RegisterService(new(statservice.StatSvc)) gorest.RegisterService(new(apisvc.ApiSvc)) c := authlib.GetConfig() email.EmailAddress = c.Smtpusername email.Password = c.Smtppassword email.SMTPServer = c.Smtpserver if c.Https_Enabled { err := http.ListenAndServeTLS(":3048", c.Cirtifcate, c.PrivateKey, gorest.Handle()) if err != nil { term.Write(err.Error(), term.Error) return } } else { err := http.ListenAndServe(":3048", gorest.Handle()) if err != nil { term.Write(err.Error(), term.Error) return } } }
func (h *AuthHandler) GetUser(email string) (User, string) { term.Write("Login user email"+email, term.Debug) term.Write(Config.UserName, term.Debug) bytes, err := client.Go("ignore", "com.duosoftware.auth", "users").GetOne().ByUniqueKey(email).Ok() var user User if err == "" { if bytes != nil { var uList User err := json.Unmarshal(bytes, &uList) if err == nil { uList.Password = "******" uList.ConfirmPassword = "******" return uList, "" } else { if err != nil { term.Write("Login user Error "+err.Error(), term.Error) } } } } else { term.Write("Login user Error "+err, term.Error) } return user, "Error Validating user" }
func main() { term.GetConfig() term.Write(s.Format("20060102"), term.Debug) term.Write("Lable", term.Debug) stat.Start() go ErrorMethods() go Informaton() term.StartCommandLine() }
func main() { cebadapter.Attach("DuoAuth", func(s bool) { cebadapter.GetLatestGlobalConfig("StoreConfig", func(data []interface{}) { term.Write("Store Configuration Successfully Loaded...", term.Information) agent := cebadapter.GetAgent() agent.Client.OnEvent("globalConfigChanged.StoreConfig", func(from string, name string, data map[string]interface{}, resources map[string]interface{}) { cebadapter.GetLatestGlobalConfig("StoreConfig", func(data []interface{}) { term.Write("Store Configuration Successfully Updated...", term.Information) }) }) }) term.Write("Successfully registered in CEB", term.Information) }) authlib.SetupConfig() term.GetConfig() //go Bingo() stat.Start() go webServer() go runRestFul() term.SplashScreen("splash.art") term.Write("================================================================", term.Splash) term.Write("| Admintration Console running on :9000 |", term.Splash) term.Write("| https RestFul Service running on :3048 |", term.Splash) term.Write("| Duo v6 Auth Service 6.0 |", term.Splash) term.Write("================================================================", term.Splash) term.StartCommandLine() }
func (h *AuthHandler) AppAutherize(ApplicationID, UserID string) bool { bytes, err := client.Go("ignore", "com.duosoftware.auth", "atherized").GetOne().ByUniqueKey(ApplicationID + "-" + UserID).Ok() term.Write("AppAutherize For Application "+ApplicationID+" UserID "+UserID, term.Debug) if err == "" { if bytes != nil { var uList AppAutherize err := json.Unmarshal(bytes, &uList) if err == nil { return true } } } else { term.Write("AppAutherize Error "+err, term.Error) } return false }
//Activate user account using invitation mail send with token //GET //Url /UserActivation/sdfsdfwer23rsdff //if user activation success method will return Success func (serv RegistationService) UserActivation(token string) string { respond := "" //check user from db bytes, err := client.Go("ignore", "com.duosoftware.com", "activation").GetOne().BySearching(token).Ok() if err == "" { var uList []User err := json.Unmarshal(bytes, &uList) if err == nil || bytes == nil { //new user if len(uList) == 0 { term.Write("User Not Found", term.Debug) } else { var u User u.UserID = uList[0].UserID u.Password = uList[0].Password u.Active = true u.ConfirmPassword = uList[0].Password u.Name = uList[0].Name u.EmailAddress = uList[0].EmailAddress //Change activation status to true and save term.Write("Activate User "+u.Name+" Update User "+u.UserID, term.Debug) client.Go("ignore", "com.duosoftware.auth", "users").StoreObject().WithKeyField("EmailAddress").AndStoreOne(u).Ok() respond = "true" var Activ ActivationEmail Activ.EmailAddress = u.EmailAddress //set token empty and save Activ.Token = "" client.Go("ignore", "com.duosoftware.com", "Activation").StoreObject().WithKeyField("EmailAddress").AndStoreOne(Activ).Ok() Email(u.EmailAddress, Activ.Token, "Activated") respond = "Success" } } } else { term.Write("Activation Fail ", term.Debug) } return respond }
func (h *AuthHandler) GetAuthCode(ApplicationID, UserID, URI string) string { var a AuthCode a.ApplicationID = ApplicationID a.UserID = UserID a.URI = URI a.Code = common.RandText(10) client.Go("ignore", "com.duosoftware.auth", "authcode").StoreObject().WithKeyField("Code").AndStoreOne(a).Ok() term.Write("GetAuthCode for "+ApplicationID+" with SecurityToken :"+UserID, term.Debug) return a.Code }
func getCirt(UserID, recordID string, s SecInfo) Cirtificat { term.Write("Methed Invoke getCirt", term.Debug) var c Cirtificat RecID := getPODID(UserID, recordID) bytes, err := client.Go(s.SecurityToken, s.POGDomain, "cirts").GetOne().ByUniqueKey(RecID).Ok() //var t Tenant if err == "" { err := json.Unmarshal(bytes, &c) if err == nil { return c } else { term.Write("Methed Invoke getCirt :"+err.Error(), term.Error) return c } } else { term.Write("Methed Invoke getCirt :"+err, term.Error) return c } }
func (h *AuthHandler) ForgetPassword(emailaddress string) bool { u, error := h.GetUser(emailaddress) if error == "" { passowrd := common.RandText(6) u.ConfirmPassword = passowrd u.Password = passowrd term.Write("Password : "******"email"] = u.EmailAddress inputParams["name"] = u.Name inputParams["password"] = passowrd email.Send("ignore", "com.duosoftware.auth", "email", "user_resetpassword", inputParams, u.EmailAddress) term.Write("E Mail Sent", term.Debug) return true } return false }
func main() { gorest.RegisterService(new(authlib.Auth)) gorest.RegisterService(new(authlib.TenantSvc)) err := http.ListenAndServe(":6001", gorest.Handle()) if err != nil { term.Write(err.Error(), term.Error) return } fmt.Scanln() }
func addCirt(GUUserID string, p PermistionRecords, s SecInfo) { var c Cirtificat var r RecordUsers term.Write("Methed Invoke addCirt", term.Debug) c.POGid = getPODID(GUUserID, p.RecordID) c.AccessLevel = p.AccessLevel c.OtherData = p.OtherData r.RecordID = p.RecordID r.UserIDs = getUsers(p.RecordID, s) client.Go(s.SecurityToken, s.POGDomain, "cirts").StoreObject().WithKeyField("POGid").AndStoreOne(c).Ok() term.Write("Methed Invoke addCirt Insearted to com.duosoftware.pog.cirts."+c.POGid, term.Debug) for _, element := range r.UserIDs { if element == GUUserID { return } } r.UserIDs = append(r.UserIDs, GUUserID) client.Go(s.SecurityToken, s.POGDomain, "records").StoreObject().WithKeyField("RecordID").AndStoreOne(r).Ok() term.Write("Methed Invoke addCirt Inserted to com.duosoftware.pog.records."+r.RecordID, term.Debug) }
func (app AppSvc) Get(ApplicationID string) (a Application) { scurityToken := app.Context.Request().Header.Get("SecurityToken") term.Write("Get App for SecurityToken "+scurityToken, term.Debug) var h Apphanler a, err := h.Get(ApplicationID, scurityToken) if err != "" { app.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte(err)) return } return }
//User login func (serv RegistationService) Login(l Login) { bytes, err := client.Go("ignore", "com.duosoftware.auth", "users").GetOne().ByUniqueKey(l.EmailAddress).Ok() fmt.Println(l.EmailAddress, l.Password) fmt.Println("19") if err == "" { fmt.Println("20") if bytes != nil { fmt.Println("21") newUser := User{} //uList = make([]User, 0) err := json.Unmarshal(bytes, &newUser) fmt.Println("22") fmt.Println("<<<<<<<<<<<", newUser) if err == nil { fmt.Println("23") if newUser.Password == l.Password && newUser.EmailAddress == l.EmailAddress { fmt.Println("24") serv.ResponseBuilder().SetResponseCode(200).Write([]byte(newUser.Name)) //term.Write("password incorrect", term.Error) } else { fmt.Println("25") serv.ResponseBuilder().SetResponseCode(201).Write([]byte("Password Wrong ")) } } else { fmt.Println("26") if err != nil { fmt.Println("27") term.Write("Login user Error "+err.Error(), term.Error) } } } } else { fmt.Println("28") term.Write("Login user Error "+err, term.Error) serv.ResponseBuilder().SetResponseCode(201).Write([]byte(err)) } }
func (h *AuthHandler) GetSession(key, Domain string) (AuthCertificate, string) { //bytes, err := client.Go(key, "s.duosoftware.auth", "sessions").GetOne().ByUniqueKey(key).Ok() //term.Write("GetSession For SecurityToken "+key, term.Debug) a, err := session.GetSession(key, Domain) var c AuthCertificate if err == "" { c.ClientIP = a.ClientIP c.DataCaps = a.DataCaps c.Domain = a.Domain c.Email = a.Email c.Name = a.Name c.SecurityToken = a.SecurityToken c.UserID = a.UserID c.Username = a.Username return c, "" } else { term.Write("GetSession Error "+err, term.Error) } term.Write("GetSession No Session for SecurityToken "+key, term.Debug) return c, "Error Session Not Found" }
func (app AppSvc) Add(a Application) { scurityToken := app.Context.Request().Header.Get("SecurityToken") term.Write("Add App for SecurityToken "+scurityToken, term.Debug) var h Apphanler a, err := h.Add(a, scurityToken) if err != "" { app.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte(err)) return } b, _ := json.Marshal(a) app.ResponseBuilder().SetResponseCode(200).WriteAndOveride(b) return //return a }
func getUsers(RecordID string, s SecInfo) []string { term.Write("Methed Invoke getUsers", term.Debug) var c RecordUsers //RecID = getPODID(UserID, recordID) bytes, err := client.Go(s.SecurityToken, s.POGDomain, "records").GetOne().ByUniqueKey(RecordID).Ok() //var t Tenant if err == "" { err := json.Unmarshal(bytes, &c) if err == nil { return c.UserIDs } else { return c.UserIDs } } else { return c.UserIDs } }
func (s *Scheduler) Start() { cebadapter.Attach("ProcessScheduler", func(s bool) { cebadapter.GetLatestGlobalConfig("StoreConfig", func(data []interface{}) { fmt.Println("Store Configuration Successfully Loaded...") agent := cebadapter.GetAgent() agent.Client.OnEvent("globalConfigChanged.StoreConfig", func(from string, name string, data map[string]interface{}, resources map[string]interface{}) { cebadapter.GetLatestGlobalConfig("StoreConfig", func(data []interface{}) { fmt.Println("Store Configuration Successfully Updated...") }) }) }) fmt.Println("Successfully registered in CEB") }) downloader := core.Downloader{} term.Write("Starting Serviec Console Scheduler...", term.Debug) downloader.Start() }
func (h *AuthHandler) SaveUser(u User, update bool) User { term.Write("SaveUser saving user "+u.Name, term.Debug) bytes, err := client.Go("ignore", "com.duosoftware.auth", "users").GetOne().ByUniqueKey(u.EmailAddress).Ok() if err == "" { var uList User err := json.Unmarshal(bytes, &uList) //if err == nil || bytes == nil { if err != nil { u.Active = false u.UserID = common.GetGUID() term.Write("SaveUser saving user "+u.Name+" New User "+u.UserID, term.Debug) password := u.Password u.Password = common.GetHash(u.Password) u.ConfirmPassword = common.GetHash(u.ConfirmPassword) var Activ ActivationEmail Activ.GUUserID = u.EmailAddress Activ.Token = common.RandText(10) var inputParams map[string]string inputParams = make(map[string]string) inputParams["email"] = u.EmailAddress inputParams["name"] = u.Name inputParams["token"] = Activ.Token inputParams["password"] = password email.Send("ignore", "com.duosoftware.auth", "email", "user_activate", inputParams, u.EmailAddress) term.Write("E Mail Sent", term.Debug) client.Go("ignore", "com.duosoftware.auth", "activation").StoreObject().WithKeyField("Token").AndStoreOne(Activ).Ok() term.Write("Activation stored", term.Debug) client.Go("ignore", "com.duosoftware.auth", "users").StoreObject().WithKeyField("EmailAddress").AndStoreOne(u).Ok() } else { if update { u.UserID = uList.UserID u.Password = common.GetHash(u.Password) u.ConfirmPassword = common.GetHash(u.Password) term.Write("SaveUser saving user "+u.Name+" Update User "+u.UserID, term.Debug) client.Go("ignore", "com.duosoftware.auth", "users").StoreObject().WithKeyField("EmailAddress").AndStoreOne(u).Ok() } } //} else { //term.Write("SaveUser saving user store Error #"+err.Error(), term.Error) //} } else { term.Write("SaveUser saving user fetech Error #"+err, term.Error) } u.Password = "******" u.ConfirmPassword = "******" return u }
func runRestFul() { gorest.RegisterService(new(lib.PayService)) gorest.RegisterService(new(lib.BankService)) gorest.RegisterService(new(lib.DocService)) gorest.RegisterService(new(lib.AccountService)) /* c := authlib.GetConfig() if c.Https_Enabled { err := http.ListenAndServeTLS(":4048", c.Cirtifcate, c.PrivateKey, gorest.Handle()) if err != nil { term.Write(err.Error(), term.Error) return } } else { */ err := http.ListenAndServe(":4048", gorest.Handle()) if err != nil { term.Write(err.Error(), term.Error) return } // } }
func status() { term.Write("Status is running", term.Information) }
func sendmail(receiver string, subj string, body string) { term.Write("email :"+EmailAddress, term.Debug) term.Write("name :"+Name, term.Debug) term.Write("smtp :"+SMTPServer, term.Debug) term.Write("smtp :"+Password, term.Debug) //term.Write(Lable, mType) from := mail.Address{Name, EmailAddress} to := mail.Address{"", receiver} headers := make(map[string]string) headers["From"] = from.String() headers["To"] = to.String() headers["Subject"] = subj // Setup message message := "" for k, v := range headers { message += fmt.Sprintf("%s: %s\r\n", k, v) } message += "\r\n" + body // Connect to the SMTP Server servername := SMTPServer host, _, _ := net.SplitHostPort(servername) //if(EmailAddress!="") auth := smtp.PlainAuth("", EmailAddress, Password, host) // TLS config tlsconfig := &tls.Config{ InsecureSkipVerify: true, ServerName: host, } // Here is the key, you need to call tls.Dial instead of smtp.Dial // for smtp servers running on 465 that require an ssl connection // from the very beginning (no starttls) fmt.Print(tlsconfig.Certificates) conn, err := tls.Dial("tcp", servername, tlsconfig) if err != nil { fmt.Print(err.Error()) return } c, err := smtp.NewClient(conn, host) if err != nil { fmt.Print(err.Error()) return } // Auth if err = c.Auth(auth); err != nil { fmt.Print(err.Error()) return } // To && From if err = c.Mail(from.Address); err != nil { fmt.Print(err.Error()) return } if err = c.Rcpt(to.Address); err != nil { fmt.Print(err.Error()) return } // Data w, err := c.Data() if err != nil { fmt.Print(err.Error()) return } _, err = w.Write([]byte(message)) if err != nil { fmt.Print(err.Error()) return } err = w.Close() if err != nil { fmt.Print(err.Error()) return } else { fmt.Println("\nMail sent sucessfully....") } c.Quit() }
func (h *AuthHandler) LogOut(a AuthCertificate) { client.Go("ignore", "s.duosoftware.auth", "sessions").DeleteObject().ByUniqueKey(a.SecurityToken) //client.Go("ignore", "s.duosoftware.auth", "sessions").StoreObject().WithKeyField("SecurityToken").AndStoreOne(a).Ok() term.Write("LogOut for "+a.Name+" with SecurityToken :"+a.SecurityToken, term.Debug) //return true }
//Save user using Authlib func SaveUser(u User) string { term.Write("SaveUser saving user "+u.Name, term.Debug) respond := "" token := randToken() fmt.Println("3") fmt.Println(">>>>>>>>>>>>>>>") fmt.Println(u.EmailAddress) fmt.Println("<<<<<<<<<<<<<<<") //bytes, err := client.Go("ignore", "com.duosoftware.auth", "users").GetOne().ByQuerying("EmailAddress :" + "*****@*****.**").Ok() bytes, err := client.Go("ignore", "com.duosoftware.auth", "users").GetOne().ByUniqueKey(u.EmailAddress).Ok() fmt.Println("{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{") fmt.Println(string(bytes)) fmt.Println("}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}") fmt.Println("4") if err == "" { var uList []User uList = make([]User, 0) err := json.Unmarshal(bytes, &uList) if err == nil || bytes == nil { fmt.Println("5") //new user fmt.Println(len(uList), "LLLLLLLLLLLLLLLLLLLL") if len(uList) == 0 { u.UserID = common.GetGUID() term.Write("SaveUser saving user"+u.Name+" New User "+u.UserID, term.Debug) client.Go("ignore", "com.duosoftware.auth", "users").StoreObject().WithKeyField("EmailAddress").AndStoreOne(u).Ok() respond = "true" fmt.Println("6") //save Activation mail details //EmailAddress and Token //EmailAddress KeyProperty var Activ ActivationEmail Activ.EmailAddress = u.EmailAddress Activ.Token = token client.Go("ignore", "com.duosoftware.com", "activation").StoreObject().WithKeyField("EmailAddress").AndStoreOne(Activ).Ok() fmt.Println("7") Email(u.EmailAddress, token, "Activation") } else if len(uList) == 1 { //Alredy in Registerd user //term.Write("User Already Registerd #"+err.Error(), term.Error) fmt.Println("User Already Registerd") } } else { fmt.Println("ERRRRRR") //term.Write("SaveUser saving user store Error #"+err.Error(), term.Error) respond = "false" } } else { //term.Write("SaveUser saving user fetech Error #"+err, term.Error) fmt.Println("errrrr") respond = "false" } fmt.Println("8") u.Password = "******" u.ConfirmPassword = "******" return respond }