private void registerBtn_Click(object sender, EventArgs e)
 {
     try
     {
         var firstName = Sanitize.Capitalize(FirstNameBox.Text);
         var lastName  = Sanitize.Capitalize(LastNameBox.Text);
         Validation.EmailValidation(EmailBox.Text);
         var email       = EmailBox.Text;
         var pwd         = Password(PasswordBox.Text, ConPasswordBox.Text);
         var pwdHashSalt = PasswordHash.GenerateHash(pwd);
         var PasswordH   = pwdHashSalt[0];
         var PasswordS   = pwdHashSalt[1];
         // Create a dictionary of customer to pass to CreateCustomer
         var customerReg = new Customer()
         {
             FirstName = firstName, LastName = lastName, Email = email, PasswordHash = PasswordH, PasswordSalt = PasswordS
         };
         _customer.Add(customerReg);
         MessageBox.Show("Registration Successful", "Success Message");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error in Input");
     }
     EmptyTextBox();
 }
Esempio n. 2
0
        public static void SetTitle()
        {
            string  text  = Sanitize.Title(ConsoleTrack.instructionText.Substring(5).TrimStart());
            WEScene scene = (WEScene)Systems.scene;

            if (text.Length > 0)
            {
                ConsoleTrack.instructionText = "title " + text.Substring(0, Math.Min(text.Length, 24));
            }

            short remain = (short)(24 - text.Length);

            ConsoleTrack.possibleTabs = "Example: `title My World`";
            ConsoleTrack.helpText     = "Provide a world title. Currently: \"" + scene.worldData.title + "\". " + remain.ToString() + " characters remaining.";

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                // Prevent Rename if it exceeds name length.
                if (text.Length > 24)
                {
                    UIHandler.AddNotification(UIAlertType.Error, "Invalid Title", "Title must be 24 characters or less.", 240);
                    return;
                }

                scene.worldContent.data.title = text;
                UIHandler.AddNotification(UIAlertType.Success, "New World Title", "World title set to: \"" + text + "\"", 240);
            }
        }
Esempio n. 3
0
        public static void SetDescription()
        {
            string text = Sanitize.Description(ConsoleTrack.instructionText.Substring(4).TrimStart());

            if (text.Length > 0)
            {
                ConsoleTrack.instructionText = "desc " + text.Substring(0, Math.Min(text.Length, 72));
            }

            short remain = (short)(72 - text.Length);

            ConsoleTrack.possibleTabs = "Example: `desc My Cool Level`";
            ConsoleTrack.helpText     = "Provide a level description. " + remain.ToString() + " characters remaining.";

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                // Prevent Rename if it exceeds name length.
                if (text.Length > 72)
                {
                    UIHandler.AddNotification(UIAlertType.Error, "Invalid Description", "Level description must be 72 characters or less.", 240);
                    return;
                }

                ((EditorScene)Systems.scene).levelContent.SetDescription(text);
                UIHandler.AddNotification(UIAlertType.Success, "New Description", "Description set to: \"" + text + "\"", 240);
            }
        }
Esempio n. 4
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var data = new List <string>();

            DA.GetDataList(0, data);

            Brep col    = null;
            Brep plinth = null;
            Brep swing  = null;

            DA.GetData(1, ref col);
            DA.GetData(2, ref plinth);
            DA.GetData(3, ref swing);

            var pts = new List <Point3d>();

            DA.GetDataList(4, pts);

            var containers = Sanitize.InterfaceOutput(data);

            if (!containers.Any())
            {
                return;
            }

            var terrain = Terrain.Generate(1.5, 2.5);

            foreach (Armature armature in containers)
            {
                armature.Build(terrain, col, plinth, swing, pts);

                Make.Armature(armature);
            }
        }
Esempio n. 5
0
        public static void SetTitle()
        {
            string text = Sanitize.Title(ConsoleTrack.instructionText.Substring(5).TrimStart());

            if (text.Length > 0)
            {
                ConsoleTrack.instructionText = "title " + text.Substring(0, Math.Min(text.Length, 24));
            }

            short remain = (short)(24 - text.Length);

            ConsoleTrack.possibleTabs = "Example: `title \"My Cool Level\"`";
            ConsoleTrack.helpText     = "Provide a level title. " + remain.ToString() + " characters remaining.";

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                // Prevent Rename if it exceeds name length.
                if (text.Length > 24)
                {
                    UIHandler.AddNotification(UIAlertType.Error, "Invalid Title", "Title must be 24 characters or less.", 240);
                    return;
                }

                ((EditorScene)Systems.scene).levelContent.SetTitle(text);
                UIHandler.AddNotification(UIAlertType.Success, "New Level Title", "Title set to: \"" + text + "\"", 240);
            }
        }
        public virtual string GetFileNameForFieldValue(ListItem item, string destinationPath)
        {
            var title    = item.FieldValues["Title"] as string;
            var fileName = Path.Combine(destinationPath, Sanitize.GetValidFileName(title) + ConfigurationManager.AppSettings["FieldValuesFileEnding"]);

            return(fileName);
        }
Esempio n. 7
0
        public static void SetDescription()
        {
            string  text  = Sanitize.Description(ConsoleTrack.instructionText.Substring(4).TrimStart());
            WEScene scene = (WEScene)Systems.scene;

            if (text.Length > 0)
            {
                ConsoleTrack.instructionText = "desc " + text.Substring(0, Math.Min(text.Length, 72));
            }

            short remain = (short)(72 - text.Length);

            ConsoleTrack.possibleTabs = "Example: `desc This world is awesome. You will love it.`";
            ConsoleTrack.helpText     = "Provide a description. Currently: \"" + scene.worldData.description + "\". " + remain.ToString() + " characters remaining.";

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                // Prevent Rename if it exceeds name length.
                if (text.Length > 72)
                {
                    UIHandler.AddNotification(UIAlertType.Error, "Invalid Description", "World description must be 72 characters or less.", 240);
                    return;
                }

                scene.worldContent.data.description = text;
                UIHandler.AddNotification(UIAlertType.Success, "New World Description", "Description Set: \"" + text + "\"", 240);
            }
        }
Esempio n. 8
0
    public void Sanitize()
    {
        describe("$sanitize", () =>
        {
            Module M          = new Module("testsanitize", ngSanitize.ModuleName);
            var el            = Window.Document.CreateElement("p");
            Injector injector = Angular.Bootstrap(el, M.Name);

            Sanitize sanitize = injector.Get <Sanitize>("$sanitize");

            it("should sanitize an html string", () =>
            {
                expect(sanitize("<p>this is<b onmouseover=alert('oo')>dangerous</b>data</p>")).toEqual("<p>this is<b>dangerous</b>data</p>");
            });
        });

        describe("linky Filter", () =>
        {
            Module M          = new Module("testlinkyfilter", ngSanitize.ModuleName);
            var el            = Window.Document.CreateElement("p");
            Injector injector = Angular.Bootstrap(el, M.Name);

            Filter Filter = injector.Get <Filter>("$filter");

            var linky = Filter("linky");

            it("should convert text into http link", () =>
            {
                expect(linky("http://www.hello.com")).toBe("<a href=\x22http://www.hello.com\x22>http://www.hello.com</a>");
            });
        });
    }
Esempio n. 9
0
        private void SanitizeDialogs(List <Dialog> dialogs)
        {
            var sanitize = new Sanitize();

            foreach (Dialog dialog in dialogs)
            {
                dialog.text = sanitize.GetSanitized(dialog.text);
            }
        }
Esempio n. 10
0
        public IActionResult Post(
            [FromBody] UserFormSubmission formData,
            string id)
        {
            if (!Sanitize.SanitizeString(id, out string error, Constants.RegexStrings.UserId, 50, 50))
            {
                return(BadRequest(error));
            }

            User user = GameManager.MapIdentifierToUser(id, out bool newUser);

            if (user != null)
            {
                user.LastSubmitTime = DateTime.UtcNow;
            }

            if (user?.UserState == null || newUser)
            {
                return(BadRequest("Error finding user object, try again."));
            }

            if (!Sanitize.SanitizeAllStrings(formData, out error))
            {
                return(BadRequest(error));
            }

            // Make sure HandleUserFormInput is never called concurrently for the same user.
            try
            {
                lock (user.LockObject)
                {
                    if (!user.UserState.UserRequestingCurrentPrompt(user).SubmitButton)
                    {
                        return(BadRequest("You shouldn't be able to time out on this prompt."));
                    }

                    // Cleans invalid fields and replaces with null.
                    if (user.UserState.CleanUserFormInput(user, ref formData, out error) != UserState.CleanUserFormInputResult.Invalid)
                    {
                        // Handles partial/null inputs.
                        user.UserState.HandleUserTimeout(user, formData);
                    }
                }
            }
            catch (Exception e)
            {
                error = "An unexpected error occurred, refresh and try again :(";

                // Let GameManager know so it can determine whether or not to abandon the lobby.
                GameManager.ReportGameError(ErrorType.UserSubmit, user?.LobbyId, user, e);

                return(new BadRequestObjectResult(error));
            }
            return(new OkResult());
        }
        public IActionResult Post(
            [FromBody] UserFormSubmission formData,
            string id)
        {
            if (!ModelState.IsValid)
            {
                return(new BadRequestResult());
            }

            if (!Sanitize.SanitizeString(id, out string error, Constants.RegexStrings.UserId, 50, 50))
            {
                return(BadRequest(error));
            }

            User user = GameManager.MapIdentifierToUser(id, out bool newUser);

            if (user != null)
            {
                user.LastSubmitTime = DateTime.UtcNow;
            }

            if (user?.UserState == null || newUser)
            {
                return(BadRequest("Error finding user object, try again."));
            }

            if (!Sanitize.SanitizeAllStrings(formData, out error))
            {
                return(BadRequest(error));
            }

            // Make sure HandleUserFormInput is never called concurrently for the same user.
            bool success = false;

            try
            {
                lock (user.LockObject)
                {
                    // If user form input was valid, handle it, else return the error.
                    if (user.UserState.CleanUserFormInput(user, ref formData, out error) == UserState.CleanUserFormInputResult.Valid)
                    {
                        success = user.UserState.HandleUserFormInput(user, formData, out error);
                    }
                }
            }
            catch (Exception e)
            {
                error   = "An unexpected error occurred, refresh and try again :(";
                success = false;

                // Let GameManager know so it can determine whether or not to abandon the lobby.
                GameManager.ReportGameError(ErrorType.UserSubmit, user?.LobbyId, user, e);
            }
            return(success ? new OkResult() : BadRequest(error));
        }
Esempio n. 12
0
        public object Any(Sanitize request)
        {
            _logger.Log(EErrorType.Info, " ****** Call start: Sanitize");

            EchoResponse response = new EchoResponse();

            try
            {
                TransferHeader(request, response);

                if (IsValidSessionToken(request))
                {
                    if (ConfigurationManager.AppSettings["CanSanitize"] != null && bool.Parse(ConfigurationManager.AppSettings["CanSanitize"]))
                    {
                        TechUtils tu = new TechUtils();
                        tu.Sanitize();
                        _logger.Log(EErrorType.Info, string.Format("Sanitization started"));
                    }
                    else
                    {
                        _logger.Log(EErrorType.Warning, string.Format("Sanitization not allowed - start cancelled"));
                    }


                    response.Success = true;
                }
                else
                {
                    response.Success = false;
                    response.Errors.Add(new Error()
                    {
                        Code = EErrorCodes.InvalidSession, Type = EErrorType.Error, Message = "Invalid session token"
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.Log(ex);
                response.Success = false;
                response.Errors.Add(new Error()
                {
                    Code    = EErrorCodes.GeneralError,
                    Type    = EErrorType.Error,
                    Message = string.Format("Unpexcted error: {0}", ex.Message)
                });
            }

            _logger.Log(EErrorType.Info, " ****** Call end: Sanitize");

            return(response);
        }
Esempio n. 13
0
        public IActionResult ResetUser(string id)
        {
            if (!ModelState.IsValid)
            {
                return(new BadRequestResult());
            }

            if (!Sanitize.SanitizeString(id, out string error, Constants.RegexStrings.UserId))
            {
                return(BadRequest(error));
            }
            GameManager.UnregisterUser(id);
            return(new OkResult());
        }
Esempio n. 14
0
        public IHttpActionResult Post(Comment tblComment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            //Sanitize body
            String originalBody = tblComment.comBody;
            String sant         = Sanitize.SanitizeInput(originalBody);

            tblComment.comBody = sant;
            db.Comments.Add(tblComment);
            db.SaveChanges();
            System.Diagnostics.Debug.WriteLine("Comment posted: " + tblComment.comBody);
            return(CreatedAtRoute("DefaultApi", new { id = tblComment.comID }, tblComment));
        }
Esempio n. 15
0
        static void Sanitize()
        {
            Sanitize reqSanitize = new Sanitize();

            reqSanitize.SessionToken = techUtilsToken;

            SanitizeResponse respSanitize = tuClient.PostSanitize(reqSanitize);

            if (respSanitize.Success)
            {
                Console.WriteLine(string.Format("[{0}] Sanitization - Success", DateTime.Now));
            }
            else
            {
                Console.WriteLine(string.Format("[{0}] Sanitization - Failed: Error Code - {1}, Message: {2}",
                                                DateTime.Now, respSanitize.Errors[0].Code, respSanitize.Errors[0].Message));
            }
        }
Esempio n. 16
0
        private (bool, string) InternalJoinLobby(JoinLobbyRequest request, string id)
        {
            if (!Sanitize.SanitizeString(request.DisplayName, out string _))
            {
                return(false, "DisplayName invalid.");
            }

            if (!Sanitize.SanitizeString(request.LobbyId, out string _))
            {
                return(false, "LobbyId invalid.");
            }

            User user = GameManager.MapIdentifierToUser(id, out bool newUser);

            lock (user.LockObject)
            {
                if (user.Lobby != null & user.LobbyId == request.LobbyId)
                {
                    // Another thread beat us to it. Return generic error.
                    return(false, "Try Again.");
                }

                if (user.Lobby != null)
                {
                    // Either another thread beat us to it (with multiple lobbies). Or we got the user stuck in a bad state.
                    // Unregister the user and return failure.
                    GameManager.UnregisterUser(user);
                    return(false, "Try Again.");
                }

                (bool, string)result = GameManager.RegisterUser(user, request);
                if (!result.Item1)               // Check success.
                {
                    return(false, result.Item2); // Return error message.
                }

                if (user?.Lobby == null) // Confirm user is now in a lobby.
                {
                    return(false, "Unknown error occurred while joining Lobby.");
                }

                return(true, string.Empty);
            }
        }
Esempio n. 17
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="InFullName">The full sanitized path</param>
 /// <param name="InSanitize">Dummary argument to use the sanitized overload</param>
 public FileReference(string InFullName, Sanitize InSanitize)
     : base(InFullName)
 {
 }
Esempio n. 18
0
 /// <summary>
 /// Constructor for creating a directory object directly from two strings.
 /// </summary>
 /// <param name="InFullName">The full, sanitized path name</param>
 /// <param name="InSanitize">Dummy argument used to resolve this overload</param>
 public DirectoryReference(string InFullName, Sanitize InSanitize)
     : base(InFullName)
 {
 }
Esempio n. 19
0
 public BookJson(string author, string isbn13, int pages)
 {
     Author = Sanitize.RegexReplace("( ){2,}", String.Empty, author).WhiteMatch(@"[a-zA-Z\. ]+");
     ISBN13 = Sanitize.RemoveWhitespace(isbn13).BlackList(@"\-");
     Pages  = pages;
 }
 /// <summary>
 /// Protected constructor. Initializes to the given parameters without validation.
 /// </summary>
 /// <param name="Name">The name of this entity.</param>
 /// <param name="Sanitize">Dummy argument to force overload resolution to use this implementation.</param>
 public StagedFileSystemReference(string Name, Sanitize Sanitize)
 {
     this.Name = Name;
 }
        public SanitizeResponse PostSanitize(Sanitize request)
        {
            SanitizeResponse response = Post <Sanitize, SanitizeResponse>("Sanitize", request);

            return(response);
        }
 /// <summary>
 /// Protected constructor. Initializes to the given parameters without validation.
 /// </summary>
 /// <param name="Name">The name of this entity.</param>
 /// <param name="CanonicalName">Canonical name of this entity. Should be equal to Name.ToLowerInvariant().</param>
 private StagedFileReference(string Name, Sanitize Sanitize) : base(Name, Sanitize)
 {
 }