Exemplo n.º 1
0
        public virtual async Task <DeviceCode> FindByUserCodeAsync(string userCode)
        {
            Check.NotNull(userCode, nameof(userCode));

            var deviceCodes = await DeviceFlowCodesRepository
                              .FindByUserCodeAsync(userCode)
            ;

            if (deviceCodes == null)
            {
                return(null);
            }

            return(DeserializeToDeviceCode(deviceCodes.Data));
        }
Exemplo n.º 2
0
        public virtual async Task UpdateByUserCodeAsync(string userCode, DeviceCode data)
        {
            Check.NotNull(userCode, nameof(userCode));
            Check.NotNull(data, nameof(data));


            var deviceCodes = await DeviceFlowCodesRepository
                              .FindByUserCodeAsync(userCode)
            ;

            if (deviceCodes == null)
            {
                throw new InvalidOperationException($"Could not update device code by the given userCode: {userCode}");
            }

            deviceCodes.SubjectId = data.Subject?.FindFirst(JwtClaimTypes.Subject).Value;
            deviceCodes.Data      = Serialize(data);

            await DeviceFlowCodesRepository
            .UpdateAsync(deviceCodes, autoSave : true)
            ;
        }