public CreateAccountPacketRes CreateAccount([FromBody] CreateAccountPacketReq req) { CreateAccountPacketRes res = new CreateAccountPacketRes(); // ID 겹치는지 확인 AccountDb account = _context.Accounts .AsNoTracking() .Where(a => a.AccountName == req.AccountName) .FirstOrDefault(); if (account == null) { // 가능 _context.Accounts.Add(new AccountDb() { AccountName = req.AccountName, Password = req.Password // TODO Hash로 해주기 }); bool success = _context.SaveChangesEx(); res.CreateOk = success; } else { // 불가능 res.CreateOk = false; } return(res); }
public static void SendCreateAccount(string account, string password) { CreateAccountPacketReq packet = new CreateAccountPacketReq { AccountName = account, Password = password }; Managers.Web.SendPostRequest <CreateAccountPacketRes>("account/create", packet, (res) => { Debug.Log(res.CreateOk); }); }
public void OnClickCreateButton(PointerEventData evt) { string account = Get <GameObject>((int)GameObjects.AccountName).GetComponent <InputField>().text; string password = Get <GameObject>((int)GameObjects.Password).GetComponent <InputField>().text; CreateAccountPacketReq packet = new CreateAccountPacketReq() { AccountName = account, Password = password }; Managers.Web.SendPostRequest <CreateAccountPacketRes>("account/create", packet, (res) => { Debug.Log(res.CreateOk); Get <GameObject>((int)GameObjects.AccountName).GetComponent <InputField>().text = ""; Get <GameObject>((int)GameObjects.Password).GetComponent <InputField>().text = ""; }); }