Esempio n. 1
0
        public IActionResult Index()
        {
            ViewBag.Msg = "This is a test";

            ViewBag.EncryptedMsg1 = _protectionProviderService.Encrypt(ViewBag.Msg);
            ViewBag.DecryptMsg1   = _protectionProviderService.Decrypt(ViewBag.EncryptedMsg1);

            ViewBag.EncryptedMsg2 = _protectionProviderService.Encrypt(ViewBag.Msg);
            ViewBag.DecryptMsg2   = _protectionProviderService.Decrypt(ViewBag.EncryptedMsg2);

            return(View());
        }
Esempio n. 2
0
        private async Task <IActionResult> renderForm(User user, bool isAdminEdit)
        {
            _usersPhotoService.SetUserDefaultPhoto(user);

            var userProfile = new UserProfileViewModel
            {
                IsAdminEdit      = isAdminEdit,
                Email            = user.Email,
                PhotoFileName    = user.PhotoFileName,
                Location         = user.Location,
                UserName         = user.UserName,
                FirstName        = user.FirstName,
                LastName         = user.LastName,
                Pid              = _protectionProviderService.Encrypt(user.Id.ToString()),
                IsEmailPublic    = user.IsEmailPublic,
                TwoFactorEnabled = user.TwoFactorEnabled,
                IsPasswordTooOld = await _usedPasswordsService.IsLastUserPasswordTooOldAsync(user.Id)
            };

            if (user.BirthDate.HasValue)
            {
                var pDateParts = user.BirthDate.Value.ToPersianYearMonthDay(DateTimeOffsetPart.DateTime);
                userProfile.DateOfBirthYear  = pDateParts.Year;
                userProfile.DateOfBirthMonth = pDateParts.Month;
                userProfile.DateOfBirthDay   = pDateParts.Day;
            }

            return(View(viewName: nameof(Index), model: userProfile));
        }
        public IActionResult Index()
        {
            ViewBag.Msg = "This is a test";

            ViewBag.EncryptedMsg1 = _protectionProviderService.Encrypt(ViewBag.Msg);
            ViewBag.DecryptMsg1   = _protectionProviderService.Decrypt(ViewBag.EncryptedMsg1);

            ViewBag.EncryptedMsg2 = _protectionProviderService.Encrypt(ViewBag.Msg);
            ViewBag.DecryptMsg2   = _protectionProviderService.Decrypt(ViewBag.EncryptedMsg2);

            var model = new TestModel {
                Id = 1, Name = "Test"
            };

            ViewBag.EncryptedMsg3 = _protectionProviderService.EncryptObject(model);
            ViewBag.DecryptMsg3   = _protectionProviderService.DecryptObject <TestModel>(ViewBag.EncryptedMsg3).Name;

            return(View());
        }