Esempio n. 1
0
        public async Task <JsonResult> Get()
        {
            var dbUser = await _dbContext.GetUserAsync(User.Identity.Name)
                         .ConfigureAwait(false);

            var IV = dbUser.IV;

            var firstName  = PasswordHelpers.DecryptData(dbUser.FirstName, IV);
            var surName    = PasswordHelpers.DecryptData(dbUser.Surname, IV);
            var middleName = string.IsNullOrEmpty(dbUser.MiddleName) ? string.Empty : PasswordHelpers.DecryptData(dbUser.MiddleName, IV);
            var birthDate  = string.IsNullOrEmpty(dbUser.BirthDate) ? string.Empty : PasswordHelpers.DecryptData(dbUser.BirthDate, IV);
            var city       = string.IsNullOrEmpty(dbUser.City) ? string.Empty : PasswordHelpers.DecryptData(dbUser.City, IV);
            var email      = PasswordHelpers.DecryptData(dbUser.Email, IV);

            var user = new
            {
                dbUser.Id,
                dbUser.Login,
                FirstName  = firstName,
                Surname    = surName,
                MiddleName = middleName,
                BirthDate  = birthDate,
                City       = city,
                Email      = email
            };

            return(new JsonResult(new MypageGetResponse
            {
                user = user
            }, _jsonOptions));
        }