Add real name col / citizen name prop (#12)
Still need to work on allowing the column to be edited
This commit is contained in:
parent
21ba35408e
commit
1b2540e5d2
@ -11,6 +11,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JobsJobsJobs.Shared", "Jobs
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{50B51580-9F09-41E2-BC78-DAD38C37B583}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
database\12-add-real-name.sql = database\12-add-real-name.sql
|
||||
JobsJobsJobs\Directory.Build.props = JobsJobsJobs\Directory.Build.props
|
||||
database\tables.sql = database\tables.sql
|
||||
EndProjectSection
|
||||
|
@ -3,8 +3,8 @@
|
||||
@inject AppState state
|
||||
|
||||
<Loading OnLoad=@RetrieveProfile>
|
||||
<PageTitle Title=@($"Employment Profile for {Citizen.DisplayName}") />
|
||||
<h2><a href="@Citizen.ProfileUrl" target="_blank">@Citizen.DisplayName</a></h2>
|
||||
<PageTitle Title=@($"Employment Profile for {Citizen.CitizenName}") />
|
||||
<h2><a href="@Citizen.ProfileUrl" target="_blank">@Citizen.CitizenName</a></h2>
|
||||
<h4>@Profile.Continent!.Name, @Profile.Region</h4>
|
||||
<p>@WorkTypes</p>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<PageTitle Title="Success Story" />
|
||||
|
||||
<Loading OnLoad=@RetrieveStory>
|
||||
<h3>@Citizen.DisplayName’s Success Story</h3>
|
||||
<h3>@Citizen.CitizenName’s Success Story</h3>
|
||||
<h4><FullDateTime TheDate=@Story.RecordedOn /></h4>
|
||||
@if (Story.FromHere)
|
||||
{
|
||||
|
@ -65,7 +65,8 @@ namespace JobsJobsJobs.Server.Areas.Api.Controllers
|
||||
var citizen = await _db.FindCitizenByNAUser(account.Username);
|
||||
if (citizen == null)
|
||||
{
|
||||
citizen = new Citizen(await CitizenId.Create(), account.Username, account.DisplayName, account.Url,
|
||||
citizen = new Citizen(await CitizenId.Create(), account.Username,
|
||||
string.IsNullOrWhiteSpace(account.DisplayName) ? null : account.DisplayName, null, account.Url,
|
||||
now, now);
|
||||
await _db.AddCitizen(citizen);
|
||||
}
|
||||
@ -73,7 +74,7 @@ namespace JobsJobsJobs.Server.Areas.Api.Controllers
|
||||
{
|
||||
citizen = citizen with
|
||||
{
|
||||
DisplayName = account.DisplayName,
|
||||
DisplayName = string.IsNullOrWhiteSpace(account.DisplayName) ? null : account.DisplayName,
|
||||
LastSeenOn = now
|
||||
};
|
||||
_db.UpdateCitizen(citizen);
|
||||
@ -83,7 +84,7 @@ namespace JobsJobsJobs.Server.Areas.Api.Controllers
|
||||
// Step 3 - Generate JWT
|
||||
var jwt = Auth.CreateJwt(citizen, _config);
|
||||
|
||||
return new JsonResult(new LogOnSuccess(jwt, citizen.Id.ToString(), citizen.DisplayName));
|
||||
return new JsonResult(new LogOnSuccess(jwt, citizen.Id.ToString(), citizen.CitizenName));
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
|
@ -80,13 +80,6 @@ namespace JobsJobsJobs.Server
|
||||
$"Profiles must be from noagendasocial.com; yours is {profileResponse.AccountName}");
|
||||
}
|
||||
|
||||
// If the user hasn't filled in a display name, use the username as the display name.
|
||||
// (this is what Mastodon does)
|
||||
if (string.IsNullOrWhiteSpace(profileResponse.DisplayName))
|
||||
{
|
||||
profileResponse.DisplayName = profileResponse.Username;
|
||||
}
|
||||
|
||||
return Result<MastodonAccount>.AsOk(profileResponse);
|
||||
}
|
||||
|
||||
@ -104,7 +97,7 @@ namespace JobsJobsJobs.Server
|
||||
Subject = new ClaimsIdentity(new[]
|
||||
{
|
||||
new Claim(ClaimTypes.NameIdentifier, citizen.Id.ToString()),
|
||||
new Claim(ClaimTypes.Name, citizen.DisplayName),
|
||||
new Claim(ClaimTypes.Name, citizen.CitizenName),
|
||||
}),
|
||||
Expires = DateTime.UtcNow.AddHours(2),
|
||||
Issuer = "https://noagendacareers.com",
|
||||
|
@ -49,11 +49,13 @@ namespace JobsJobsJobs.Server.Data
|
||||
m.Property(e => e.Id).HasColumnName("id").IsRequired().HasMaxLength(12)
|
||||
.HasConversion(Converters.CitizenIdConverter);
|
||||
m.Property(e => e.NaUser).HasColumnName("na_user").IsRequired().HasMaxLength(50);
|
||||
m.Property(e => e.DisplayName).HasColumnName("display_name").IsRequired().HasMaxLength(255);
|
||||
m.Property(e => e.DisplayName).HasColumnName("display_name").HasMaxLength(255);
|
||||
m.Property(e => e.ProfileUrl).HasColumnName("profile_url").IsRequired().HasMaxLength(1_024);
|
||||
m.Property(e => e.JoinedOn).HasColumnName("joined_on").IsRequired();
|
||||
m.Property(e => e.LastSeenOn).HasColumnName("last_seen_on").IsRequired();
|
||||
m.Property(e => e.RealName).HasColumnName("real_name").HasMaxLength(255);
|
||||
m.HasIndex(e => e.NaUser).IsUnique();
|
||||
m.Ignore(e => e.CitizenName);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Continent>(m =>
|
||||
|
@ -156,7 +156,7 @@ namespace JobsJobsJobs.Server.Data
|
||||
query = query.Where(it => citizenIds.Contains(it.Citizen.Id));
|
||||
}
|
||||
|
||||
return await query.Select(x => new ProfileSearchResult(x.Citizen.Id, x.Citizen.DisplayName,
|
||||
return await query.Select(x => new ProfileSearchResult(x.Citizen.Id, x.Citizen.CitizenName,
|
||||
x.Profile.SeekingEmployment, x.Profile.RemoteWork, x.Profile.FullTime, x.Profile.LastUpdatedOn))
|
||||
.ToListAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace JobsJobsJobs.Server.Data
|
||||
await db.Successes
|
||||
.Join(db.Citizens, s => s.CitizenId, c => c.Id, (s, c) => new { Success = s, Citizen = c })
|
||||
.OrderByDescending(it => it.Success.RecordedOn)
|
||||
.Select(it => new StoryEntry(it.Success.Id, it.Citizen.Id, it.Citizen.DisplayName,
|
||||
.Select(it => new StoryEntry(it.Success.Id, it.Citizen.Id, it.Citizen.CitizenName,
|
||||
it.Success.RecordedOn, it.Success.FromHere, it.Success.Story != null))
|
||||
.ToListAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
@ -8,8 +8,15 @@ namespace JobsJobsJobs.Shared
|
||||
public record Citizen(
|
||||
CitizenId Id,
|
||||
string NaUser,
|
||||
string DisplayName,
|
||||
string? DisplayName,
|
||||
string? RealName,
|
||||
string ProfileUrl,
|
||||
Instant JoinedOn,
|
||||
Instant LastSeenOn);
|
||||
Instant LastSeenOn)
|
||||
{
|
||||
/// <summary>
|
||||
/// The user's name by which they should be known
|
||||
/// </summary>
|
||||
public string CitizenName => RealName ?? DisplayName ?? NaUser;
|
||||
}
|
||||
}
|
||||
|
8
src/database/12-add-real-name.sql
Normal file
8
src/database/12-add-real-name.sql
Normal file
@ -0,0 +1,8 @@
|
||||
ALTER TABLE jjj.citizen ALTER COLUMN display_name DROP NOT NULL;
|
||||
ALTER TABLE jjj.citizen ADD COLUMN real_name VARCHAR(255);
|
||||
|
||||
COMMENT ON COLUMN jjj.citizen.real_name
|
||||
IS 'The real name of the user';
|
||||
|
||||
-- This can be run as often as needed
|
||||
UPDATE jjj.citizen SET display_name = NULL WHERE display_name = na_user;
|
Loading…
Reference in New Issue
Block a user