public ActionResult <IEnumerable <string> > PostCreateManagerAccount([FromBody] MessageAccount account) { var result = AccountDAO.GenerateCompanyAccount(context, account).Split('_'); Producer producer = new Producer(); MessageAccountDTO messageDTO = new MessageAccountDTO(result[0], result[1], account.Email); producer.PublishMessage(message: JsonConvert.SerializeObject(messageDTO), "AccountToEmail"); return(new JsonResult(rm.Success("Login successful", result))); }
private void AddMessage(StringBuilder buf) { MessageAccount messageAccount = MessageAccountParser.Instance.Parse(Message.Headers); PutKeyValueInto(buf, "account", messageAccount.Name); PutKeyValueInto(buf, "msgType", GetMessageType(Message)); PutKeyValueInto(buf, "msgId", Message.Id); PutKeyValueInto(buf, "corrId", Message.CorrelationId); PutKeyValueInto(buf, "returnAddress", Message.ReturnAddress); PutKeyValueInto(buf, "winIdentName", Message.WindowsIdentityName); }
public ActionResult <IEnumerable <string> > PostCreateCompany([FromBody] CompanyDataDTO companyDataDTO) { try { var company = CompanyDAO.CreateCompany(companyDataDTO); var account = companyDataDTO.AccountDTO; var messageAccount = new MessageAccount(company.CompanyId, account.Fullname, account.Email, 2); Producer producer = new Producer(); producer.PublishMessage(message: JsonConvert.SerializeObject(messageAccount), "AccountGenerate"); return(new JsonResult(rm.Success("Save success"))); } catch { return(new JsonResult(rm.Error("Save fail"))); } }
void ISceneMenuMessages.SetMessage(MessageAccount message) { MessageAccount m; bool success = false; UserClient user = message.Users[0] as UserClient; if (message.State == MessageAccount.StateType.SignUp) { success = _data.SignUp(message.Email, message.Password, message.Nick); } else if (message.State == MessageAccount.StateType.SignIn) { IUserProfile p = _data.SignIn(message.Email, message.Password); if (p != null) { success = true; user.UpdateProfile(p); MessageProfile mm = new MessageProfile(user.Nick, 0); mm.Users.Add(message.Users[0]); ICommand cc = new CommandSendMessageNetwork(mm); GetScenario().Set(cc); } } else if (message.State == MessageAccount.StateType.SignOut) { success = true; user.Nick = string.Empty; } else if (message.State == MessageAccount.StateType.ChangePassword) { if (user.Nick != null) { _data.UpdatePassword(user.Nick, message.Password); success = true; } } m = new MessageAccount(message.State, success); m.Users.Add(message.Users[0]); ICommand c = new CommandSendMessageNetwork(m); GetScenario().Set(c); }
public static string GenerateCompanyAccount(DeverateContext context, MessageAccount ms) { Account account = new Account(); var items = ms.Fullname.Split(' '); string username = items[items.Length - 1]; for (int i = 0; i < items.Length - 1; i++) { username += items[i].ElementAt(0); } List <Account> accounts = context.Account.ToList(); username = username.ToUpper() + (accounts[accounts.Count - 1].AccountId + 1); username = RemoveVietnameseTone(username); bool includeLowercase = true; bool includeUppercase = true; bool includeNumeric = true; bool includeSpecial = true; bool includeSpaces = false; int lengthOfPassword = 16; string password = PasswordGenerator.GeneratePassword(includeLowercase, includeUppercase, includeNumeric, includeSpecial, includeSpaces, lengthOfPassword); while (!PasswordGenerator.PasswordIsValid(includeLowercase, includeUppercase, includeNumeric, includeSpecial, includeSpaces, password)) { password = PasswordGenerator.GeneratePassword(includeLowercase, includeUppercase, includeNumeric, includeSpecial, includeSpaces, lengthOfPassword); } string salt = BCrypt.Net.BCrypt.GenerateSalt(13); string encodedPassword = BCrypt.Net.BCrypt.HashPassword(password, salt); account.Username = username.ToUpper(); account.Password = encodedPassword; account.Fullname = ms.Fullname; account.Gender = false; account.JoinDate = DateTime.Now; account.RoleId = ms.Role; account.CompanyId = ms.CompanyId; account.IsActive = true; context.Account.Add(account); context.SaveChanges(); return(username.ToUpper() + "_" + password); }