private static void CreateReceived(object sender, JsonClient.JsonMessageResponceArgs e) { CreateUserResponce responce = e.ResponceMessage as CreateUserResponce; if (responce == null) { Console.WriteLine("Invalid responce" + e.ResponceMessage.MessageName); } else { Console.WriteLine(responce.OK ? "Create OK" : "Create Failed"); Console.WriteLine(responce.Responce); } ClearWait(); }
protected JsonMessage CreateUser(CreateUserRequest request) { CreateUserResponce responce = new CreateUserResponce(); responce.OK = false; responce.Responce = "Invalid"; if (request != null && Config.AllowRegistration) { if (!DB.CheckEmailExists(request.Email)) { // build the salt RijndaelManaged crypto = new RijndaelManaged(); crypto.BlockSize = 256; crypto.GenerateIV(); crypto.GenerateKey(); string key = Convert.ToBase64String(crypto.Key); string iv = Convert.ToBase64String(crypto.IV); string sharedKey = key + ":" + iv; var user = DB.AddUser(request.Email, HashPassword(request.Password, iv), sharedKey); // send the validation email Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("%NAME", request.Email); args.Add("%TOKEN", user.EmailToken); SendEmail(request.Email, "CreateUser", args); // tell them it worked responce.OK = true; responce.Responce = user.UserID; SendUserUpdate(user.UserID); } } return(responce); }