Exemple #1
0
        public virtual async Task StoreDeviceAuthorizationAsync(string deviceCode, string userCode, DeviceCode data)
        {
            Check.NotNull(deviceCode, nameof(deviceCode));
            Check.NotNull(userCode, nameof(userCode));
            Check.NotNull(data, nameof(data));

            await DeviceFlowCodesRepository
            .InsertAsync(
                new DeviceFlowCodes(GuidGenerator.Create())
            {
                DeviceCode   = deviceCode,
                UserCode     = userCode,
                ClientId     = data.ClientId,
                SubjectId    = data.Subject?.FindFirst(JwtClaimTypes.Subject).Value,
                CreationTime = data.CreationTime,
                Expiration   = data.CreationTime.AddSeconds(data.Lifetime),
                Data         = Serialize(data)
            }
                );
        }