public void HandleRequest(IRequest request) { var email = request.Data.GetOrDefault <string>(k.email); var password = request.Data.GetOrDefault <string>(k.password); //is the server open? var si = _serverInfoManager.GetServerInfo(); if (!si.IsOpen) { throw new PerpetuumException(ErrorCodes.InviteOnlyServer); } var account = new Account { Email = email, Password = password, AccessLevel = AccessLevel.normal, CampaignId = "{\"host\":\"opencreate\"}" }; if (_accountRepository.Get(account.Email, account.Password) != null) { Message.Builder.FromRequest(request).WithError(ErrorCodes.AccountAlreadyExists).Send(); return; } _accountRepository.Insert(account); Message.Builder.FromRequest(request).SetData(k.account, account.ToDictionary()).Send(); }
public void HandleRequest(IRequest request) { var serverInfo = _serverInfoManager.GetServerInfo(); var data = serverInfo.Serialize(); Message.Builder.FromRequest(request).WithData(data).Send(); }
public void HandleRequest(IRequest request) { var serverInfo = ServerInfo.Deserialize(request.Data); _serverInfoManager.SaveServerInfoToDb(serverInfo); serverInfo = _serverInfoManager.GetServerInfo(); Message.Builder.FromRequest(request).WithData(serverInfo.Serialize()).Send(); _serverInfoManager.PostCurrentServerInfoToWebService(); }
public void HandleRequest(IRequest request) { var email = request.Data.GetOrDefault <string>(k.email); var password = request.Data.GetOrDefault <string>(k.password); //is the server open? var si = _serverInfoManager.GetServerInfo(); if (!si.IsOpen) { throw new PerpetuumException(ErrorCodes.InviteOnlyServer); } // if an account was already created using this session, reject this creation attempt. if (request.Session.AccountCreatedInSession) { throw new PerpetuumException(ErrorCodes.MaxIterationsExceeded); } //If email is not a well-formed email, reject this creation attempt try { var addr = new System.Net.Mail.MailAddress(email); } catch { //TODO: Client Fixme - Client needs good error code for bad-email input throw new PerpetuumException(ErrorCodes.InvalidAttribute); } var account = new Account { Email = email, Password = password, AccessLevel = AccessLevel.normal, CampaignId = "{\"host\":\"opencreate\"}" }; //If email exists - throw error if (_accountRepository.Get(account.Email, account.Password) != null) { Message.Builder.FromRequest(request).WithError(ErrorCodes.AccountAlreadyExists).Send(); return; } _accountRepository.Insert(account); // if we get this far, make sure we can't sit here and make accounts. request.Session.AccountCreatedInSession = true; Message.Builder.FromRequest(request).SetData(k.account, account.ToDictionary()).Send(); }
public void HandleRequest(IRequest request) { var email = request.Data.GetOrDefault <string>(k.email); var password = request.Data.GetOrDefault <string>(k.password); //is the server open? var si = _serverInfoManager.GetServerInfo(); if (!si.IsOpen) { throw new PerpetuumException(ErrorCodes.InviteOnlyServer); } // if an account was already created using this session, reject this creation attempt. if (request.Session.AccountCreatedInSession) { throw new PerpetuumException(ErrorCodes.AccountAlreadyExists); } var account = new Account { Email = email, Password = password, AccessLevel = AccessLevel.normal, CampaignId = "{\"host\":\"opencreate\"}" }; if (_accountRepository.Get(account.Email, account.Password) != null) { Message.Builder.FromRequest(request).WithError(ErrorCodes.AccountAlreadyExists).Send(); return; } _accountRepository.Insert(account); // if we get this far, make sure we can't sit here and make accounts. request.Session.AccountCreatedInSession = true; Db.Query().CommandText("extensionPointsInject") .SetParameter("@accountID", account.Id) .SetParameter("@points", 40000) .ExecuteNonQuery(); Message.Builder.FromRequest(request).SetData(k.account, account.ToDictionary()).Send(); }