//When the Submit button is clicked, this method is called.
        private void Submit()
        {
            // Check that all of the fields have valid input.
            if (!IsInputValid())
            {
                return;
            }
            Database db = new Database();

            //Check if the password has changed or not.
            if (!String.IsNullOrEmpty(Password) && Password.Length > 0)
            {
                SelectedService.HashedPassword = PasswordCipher.Encrypt(Password, new UserInfo().MasterPassword);
            }
            SelectedService.LastUpdated = DateTime.Now.AddHours(-1); // The time on PCs is one hour ahead for some reason.
            //Attempt to update the service in the database, then close the window.
            if (db.UpdateService(SelectedService))
            {
                Core.PrintDebug(String.Format("Service {0} updated successfully.", SelectedService.ServiceName));
                this.CloseAction();
            }
            else
            {
                //Show the errors to the user.
                this.ErrorsList.Clear();
                this.ErrorsList.Add("An error occured.");
                this.Errors = true;
            }
        }
        private void Submit()
        {
            if (!IsInputValid())
            {
                return;
            }
            Database db      = new Database();
            Service  service = new Service();

            service.ServiceName    = this.ServiceName;
            service.UserName       = this.LoginName;
            service.Email          = this.EmailAddress;
            service.Website        = this.Website;
            service.HashedPassword = PasswordCipher.Encrypt(this.Password, new UserInfo().MasterPassword);
            service.PasswordHash   = "";
            service.Description    = this.Description;
            service.LastUpdated    = DateTime.Now.AddHours(-1); // The time on PCs is one hour ahead for some reason.
            if (db.AddService(service))
            {
                Core.PrintDebug(String.Format("Service {0} added successfully.", service.ServiceName));
                this.CloseAction();
            }
            else
            {
                this.ErrorsList.Clear();
                this.ErrorsList.Add("An error occured.");
                this.Errors = true;
            }
        }
예제 #3
0
        protected string Token(Usuario _usuario)
        {
            string StartToken = PasswordCipher.Encrypt(_usuario.Username);
            string MidToken   = PasswordCipher.Encrypt(_usuario.Fullname);
            string EndToken   = PasswordCipher.Encrypt("superUltraSecretToken");

            return($"{StartToken}.{MidToken}.{EndToken}");
        }