コード例 #1
0
        //This generate a refresh token for the user by updating the sliding expiration field of the token
        public string GenerateUserRefreshToken(UserTokenData userTokenData)
        {
            int periodSliding = _configurationReader.GetSlidingExpiration();

            var freshUserTokenData = new UserTokenData();
            var now = DateTime.Now;

            freshUserTokenData.SlidingExpiration  = now.AddMinutes(periodSliding);
            freshUserTokenData.AbsoluteExpiration = userTokenData.AbsoluteExpiration;
            freshUserTokenData.PresentTime        = DateTime.Now;
            freshUserTokenData.CipherUserName     = userTokenData.CipherUserName;

            var newToken = AesHelper
                           .Encrypt(
                JsonConvert
                .SerializeObject(freshUserTokenData));

            return(newToken);
        }