Fix Styling for kanban board, removed encrpytion for gmail as it was affecting connection

This commit is contained in:
cesnimda
2026-03-21 20:03:50 +01:00
parent 793ed6eb65
commit 2b0e86f0ac
6 changed files with 54 additions and 26 deletions
+18 -1
View File
@@ -5,12 +5,14 @@ using System.Data.Common;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.IdentityModel.Tokens;
using JobTrackerApi.Models;
using JobTrackerApi.Services;
using System.Diagnostics;
using System.IdentityModel.Tokens.Jwt;
using System.Net;
using System.IO;
using System.Security.Cryptography;
using JobTrackerApi.Services.JobImport;
using JobTrackerApi.Services.JobImport.Plugins;
@@ -74,7 +76,22 @@ builder.Services.AddCors(options =>
// Add controllers
builder.Services.AddControllers();
builder.Services.AddDataProtection();
var dataRoot = (builder.Configuration["Data:Root"] ?? "").Trim();
if (string.IsNullOrWhiteSpace(dataRoot))
{
dataRoot = builder.Environment.ContentRootPath;
}
if (!Path.IsPathRooted(dataRoot))
{
dataRoot = Path.Combine(builder.Environment.ContentRootPath, dataRoot);
}
Directory.CreateDirectory(dataRoot);
var dataProtectionKeysPath = Path.Combine(dataRoot, "keys");
Directory.CreateDirectory(dataProtectionKeysPath);
builder.Services.AddDataProtection()
.PersistKeysToFileSystem(new DirectoryInfo(dataProtectionKeysPath))
.SetApplicationName("JobTracker");
builder.Services.AddHostedService<RulesHostedService>();
builder.Services.AddHostedService<DailyExportHostedService>();
builder.Services.AddHostedService<JobEnrichmentHostedService>();
+10 -1
View File
@@ -1,6 +1,7 @@
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Security.Cryptography;
using JobTrackerApi.Data;
using JobTrackerApi.Models;
using Microsoft.AspNetCore.DataProtection;
@@ -230,7 +231,15 @@ public sealed class GmailOAuthService : IGmailOAuthService
return _protector.Unprotect(connection.EncryptedAccessToken);
}
var refreshToken = _protector.Unprotect(connection.EncryptedRefreshToken);
string refreshToken;
try
{
refreshToken = _protector.Unprotect(connection.EncryptedRefreshToken);
}
catch (CryptographicException)
{
throw new InvalidOperationException("Your stored Gmail connection can no longer be decrypted after a server key change. Disconnect Gmail and connect it again.");
}
var refreshed = await RefreshAccessTokenAsync(refreshToken, cancellationToken);
var accessToken = refreshed.access_token?.Trim();
if (string.IsNullOrWhiteSpace(accessToken))