/// <summary> /// Initializes a new instance of the <see cref="GetDeviceCodeResponse"/> class. /// </summary> /// <param name="errors">errors.</param> /// <param name="deviceCode">device_code.</param> public GetDeviceCodeResponse( IList <Models.Error> errors = null, Models.DeviceCode deviceCode = null) { this.Errors = errors; this.DeviceCode = deviceCode; }
/// <summary> /// Initializes a new instance of the <see cref="CreateDeviceCodeRequest"/> class. /// </summary> /// <param name="idempotencyKey">idempotency_key.</param> /// <param name="deviceCode">device_code.</param> public CreateDeviceCodeRequest( string idempotencyKey, Models.DeviceCode deviceCode) { this.IdempotencyKey = idempotencyKey; this.DeviceCode = deviceCode; }
public Builder( string idempotencyKey, Models.DeviceCode deviceCode) { this.idempotencyKey = idempotencyKey; this.deviceCode = deviceCode; }
public async Task UpdateByUserCodeAsync(string userCode, Models.DeviceCode data) { if (userCode == null || data == null) { return; } using (var connection = new SqlConnection(_dapperStoreOptions.DbConnectionString)) { var sql = $@" SELECT DeviceCode, UserCode, SubjectId, ClientId, CreationTime, Expiration, Data FROM DeviceFlowCodes WHERE UserCode = @userCode; "; var deviceFlowCode = await connection.QueryFirstOrDefaultAsync <Entities.DeviceFlowCodes>(sql, new { userCode }); if (deviceFlowCode == null) { return; } var entity = new Entities.DeviceFlowCodes { DeviceCode = deviceFlowCode.DeviceCode, UserCode = userCode, ClientId = data.ClientId, SubjectId = data.Subject?.FindFirst(JwtClaimTypes.Subject).Value, CreationTime = data.CreationTime, Expiration = data.CreationTime.AddSeconds(data.Lifetime), Data = _persistentGrantSerializer.Serialize(data) }; sql = $@" UPDATE DeviceFlowCodes SET DeviceCode = @DeviceCode, UserCode = @UserCode, SubjectId = @SubjectId, ClientId = @ClientId, CreationTime = @CreationTime, Expiration = @Expiration, Data = @Data WHERE UserCode = @UserCode "; await connection.ExecuteAsync(sql, new { entity.DeviceCode, entity.UserCode, entity.SubjectId, entity.ClientId, entity.CreationTime, entity.Expiration, entity.Data }); } }
public Builder DeviceCode(Models.DeviceCode deviceCode) { this.deviceCode = deviceCode; return(this); }
public CreateDeviceCodeResponse(IList <Models.Error> errors = null, Models.DeviceCode deviceCode = null) { Errors = errors; DeviceCode = deviceCode; }
public async Task StoreDeviceAuthorizationAsync(string deviceCode, string userCode, Models.DeviceCode data) { if (deviceCode == null || userCode == null || data == null) { return; } using (var connection = new SqlConnection(_dapperStoreOptions.DbConnectionString)) { var entity = new Entities.DeviceFlowCodes { DeviceCode = deviceCode, UserCode = userCode, ClientId = data.ClientId, SubjectId = data.Subject?.FindFirst(JwtClaimTypes.Subject).Value, CreationTime = data.CreationTime, Expiration = data.CreationTime.AddSeconds(data.Lifetime), Data = _persistentGrantSerializer.Serialize(data) }; var sql = $@" INSERT INTO DeviceFlowCodes(DeviceCode, UserCode, SubjectId, ClientId, CreationTime, Expiration, Data) VALUES(@DeviceCode, @UserCode, @SubjectId, @ClientId, @CreationTime, @Expiration, @Data); "; await connection.ExecuteAsync(sql, new { entity.DeviceCode, entity.UserCode, entity.SubjectId, entity.ClientId, entity.CreationTime, entity.Expiration, entity.Data }); } }
public Builder DeviceCode(Models.DeviceCode value) { deviceCode = value; return(this); }