public override int GetHashCode() { int hashCode = 456544551; if (Context != null) { hashCode += Context.GetHashCode(); } if (Errors != null) { hashCode += Errors.GetHashCode(); } if (DeviceCodes != null) { hashCode += DeviceCodes.GetHashCode(); } if (Cursor != null) { hashCode += Cursor.GetHashCode(); } return(hashCode); }
/// <summary> /// Updates device authorization, searching by user code. /// </summary> /// <param name="userCode">The user code.</param> /// <param name="data">The data.</param> /// <returns></returns> public Task UpdateByUserCodeAsync(string userCode, DeviceCode data) { var existing = DeviceCodes.FindByUserCode(userCode); if (existing == null) { _logger.LogError("{userCode} not found in database", userCode); throw new InvalidOperationException("Could not update device code"); } var entity = ToEntity(data, existing.DeviceCode, userCode); _logger.LogDebug("{userCode} found in database", userCode); existing.SubjectId = data.Subject?.FindFirst(JwtClaimTypes.Subject).Value; existing.Data = entity.Data; try { existing.Save(); } catch (Exception ex) { _logger.LogWarning("exception updating {userCode} user code in database: {error}", userCode, ex.Message); } return(Task.FromResult(0)); }
/// <summary> /// Finds device authorization by device code. /// </summary> /// <param name="deviceCode">The device code.</param> /// <returns></returns> public Task <DeviceCode> FindByDeviceCodeAsync(string deviceCode) { var deviceFlowCodes = DeviceCodes.FindByDeviceCode(deviceCode); var model = ToModel(deviceFlowCodes?.Data); _logger.LogDebug("{deviceCode} found in database: {deviceCodeFound}", deviceCode, model != null); return(Task.FromResult(model)); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is ListDeviceCodesResponse other && ((Context == null && other.Context == null) || (Context?.Equals(other.Context) == true)) && ((Errors == null && other.Errors == null) || (Errors?.Equals(other.Errors) == true)) && ((DeviceCodes == null && other.DeviceCodes == null) || (DeviceCodes?.Equals(other.DeviceCodes) == true)) && ((Cursor == null && other.Cursor == null) || (Cursor?.Equals(other.Cursor) == true))); }
/// <summary> /// Removes the device authorization, searching by device code. /// </summary> /// <param name="deviceCode">The device code.</param> /// <returns></returns> public Task RemoveByDeviceCodeAsync(string deviceCode) { var deviceFlowCodes = DeviceCodes.FindByDeviceCode(deviceCode); if (deviceFlowCodes != null) { _logger.LogDebug("removing {deviceCode} device code from database", deviceCode); try { deviceFlowCodes.Delete(); } catch (Exception ex) { _logger.LogInformation("exception removing {deviceCode} device code from database: {error}", deviceCode, ex.Message); } } else { _logger.LogDebug("no {deviceCode} device code found in database", deviceCode); } return(Task.FromResult(0)); }