Add OAth flow for Gmail and update tables and UI
This commit is contained in:
@@ -20,6 +20,29 @@ namespace JobTrackerApi.Controllers
|
||||
private string? CurrentUserId =>
|
||||
User?.FindFirstValue(ClaimTypes.NameIdentifier) ?? User?.FindFirstValue("sub");
|
||||
|
||||
private static string? NormalizeSource(string? source)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(source)) return null;
|
||||
var value = source.Trim();
|
||||
|
||||
if (Uri.TryCreate(value, UriKind.Absolute, out var uri) && !string.IsNullOrWhiteSpace(uri.Host))
|
||||
{
|
||||
value = uri.Host;
|
||||
}
|
||||
|
||||
value = value.Replace("www.", "", StringComparison.OrdinalIgnoreCase).Trim().Trim('/');
|
||||
var lower = value.ToLowerInvariant();
|
||||
|
||||
return lower switch
|
||||
{
|
||||
"linkedin" or "linkedin.com" => "LinkedIn",
|
||||
"finn" or "finn.no" => "Finn",
|
||||
"nav" or "nav.no" => "NAV",
|
||||
"jobbnorge" or "jobbnorge.no" => "Jobbnorge",
|
||||
_ => string.Join(" ", value.Split(new[] { ' ', '-', '_' }, StringSplitOptions.RemoveEmptyEntries).Select(part => char.ToUpperInvariant(part[0]) + part[1..].ToLowerInvariant()))
|
||||
};
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<List<Company>>> GetAll(CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -86,7 +109,7 @@ namespace JobTrackerApi.Controllers
|
||||
OwnerUserId = string.IsNullOrWhiteSpace(userId) ? null : userId,
|
||||
Name = name,
|
||||
Location = string.IsNullOrWhiteSpace(request.Location) ? null : request.Location.Trim(),
|
||||
Source = string.IsNullOrWhiteSpace(request.Source) ? null : request.Source.Trim(),
|
||||
Source = NormalizeSource(request.Source),
|
||||
};
|
||||
|
||||
_db.Companies.Add(company);
|
||||
@@ -111,7 +134,7 @@ namespace JobTrackerApi.Controllers
|
||||
|
||||
company.Name = name;
|
||||
company.Location = string.IsNullOrWhiteSpace(request.Location) ? null : request.Location.Trim();
|
||||
company.Source = string.IsNullOrWhiteSpace(request.Source) ? null : request.Source.Trim();
|
||||
company.Source = NormalizeSource(request.Source);
|
||||
|
||||
company.RecruiterName = string.IsNullOrWhiteSpace(request.RecruiterName) ? null : request.RecruiterName.Trim();
|
||||
company.RecruiterEmail = string.IsNullOrWhiteSpace(request.RecruiterEmail) ? null : request.RecruiterEmail.Trim();
|
||||
|
||||
Reference in New Issue
Block a user