Skip to content

Commit

Permalink
Update ApplicationUser
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Mar 16, 2024
1 parent 27d7c3f commit 49ec9ee
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 55 deletions.
3 changes: 2 additions & 1 deletion MyApp.ServiceInterface/Data/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ public class AppConfig
public string LocalBaseUrl { get; set; }
public string PublicBaseUrl { get; set; }
public string CacheDir { get; set; }
public string ProfilesDir { get; set; }
public string? GitPagesBaseUrl { get; set; }
public List<ApplicationUser> ModelUsers { get; set; } = [];
public ApplicationUser DefaultUser { get; set; } = new()
{
Model = "unknown",
UserName = "unknown",
ProfileUrl = "/img/profiles/user2.svg",
ProfilePath = "/img/profiles/user2.svg",
};

public ApplicationUser GetApplicationUser(string model)
Expand Down
6 changes: 2 additions & 4 deletions MyApp.ServiceInterface/Data/ApplicationUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ namespace MyApp.Data;
[Alias("AspNetUsers")]
public class ApplicationUser : IdentityUser
{
public string? FirstName { get; set; }
public string? LastName { get; set; }
public string? ProfileUrl { get; set; }
public string? DisplayName { get; set; }
public string? ProfilePath { get; set; }
public string? Model { get; set; }
}

4 changes: 2 additions & 2 deletions MyApp.ServiceInterface/Data/CustomUserSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public override async Task<ClaimsPrincipal> CreateAsync(ApplicationUser user)

var claims = new List<Claim>();
// Add additional claims here
if (user.ProfileUrl != null)
if (user.ProfilePath != null)
{
claims.Add(new Claim(JwtClaimTypes.Picture, user.ProfileUrl));
claims.Add(new Claim(JwtClaimTypes.Picture, user.ProfilePath));
}

identity.AddClaims(claims);
Expand Down
2 changes: 1 addition & 1 deletion MyApp/Components/Shared/QuestionPost.razor
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
var user = AppConfig.GetApplicationUser(answer.Model);
}
<div class="mt-8 flex flex-col items-center">
<img class="w-20 h-20 inline-block" src="@user.ProfileUrl">
<img class="w-20 h-20 inline-block" src="@user.UserName.GetAvatarUrl()">
<div class="text-center whitespace-nowrap text-sm font-semibold">@user.UserName</div>
</div>
</div>
Expand Down
48 changes: 19 additions & 29 deletions MyApp/Configure.Db.Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,106 +84,96 @@ await EnsureUserAsync(new ApplicationUser
{
UserName = "admin",
Email = "admin@email.com",
FirstName = "Admin",
LastName = "User",
DisplayName = "Administrator",
EmailConfirmed = true,
}, "p@55wOrd", allRoles);

await EnsureUserAsync(new ApplicationUser
{
UserName = "human",
Email = "human@email.com",
FirstName = "Human",
LastName = "User",
DisplayName = "Human",
EmailConfirmed = true,
ProfileUrl = "/img/profiles/user1.svg",
ProfilePath = "/profiles/hu/human.svg",
}, "p@55wOrd");

await EnsureUserAsync(new ApplicationUser
{
UserName = "phi",
Email = "phi@email.com",
FirstName = "Phi-2",
LastName = "2.7B",
DisplayName = "Phi-2 2.7B",
EmailConfirmed = true,
ProfileUrl = "/img/profiles/phi-2.svg",
ProfilePath = "/profiles/ph/phi-2.svg",
Model = "phi", //3B
}, "p@55wOrd");

await EnsureUserAsync(new ApplicationUser
{
UserName = "gemma-2b",
Email = "gemma-2b@email.com",
FirstName = "Gemma",
LastName = "2B",
DisplayName = "Gemma 2B",
EmailConfirmed = true,
ProfileUrl = "/img/profiles/gemma-2b.svg",
ProfilePath = "/profiles/ge/gemma-2b.svg",
Model = "gemma:2b", //3B
}, "p@55wOrd");

await EnsureUserAsync(new ApplicationUser
{
UserName = "starcoder2-3b",
Email = "starcoder2-3b@email.com",
FirstName = "StarCoder2",
LastName = "3B",
DisplayName = "StarCoder2 3B",
EmailConfirmed = true,
ProfileUrl = "/img/profiles/starcoder-3b.png",
ProfilePath = "/profiles/st/starcoder-3b.png",
Model = "starcoder2:3b", //3B
}, "p@55wOrd");

await EnsureUserAsync(new ApplicationUser
{
UserName = "gemma",
Email = "gemma@email.com",
FirstName = "Gemma",
LastName = "7B",
DisplayName = "Gemma 7B",
EmailConfirmed = true,
ProfileUrl = "/img/profiles/gemma-7b.svg",
ProfilePath = "/profiles/ge/gemma-7b.svg",
Model = "gemma", //9B
}, "p@55wOrd");

await EnsureUserAsync(new ApplicationUser
{
UserName = "codellama",
Email = "codellama-13B@email.com",
FirstName = "Code Llama",
LastName = "7B",
DisplayName = "Code Llama 7B",
EmailConfirmed = true,
ProfileUrl = "/img/profiles/codellama.svg",
ProfilePath = "/profiles/co/codellama.svg",
Model = "codellama", //7B
}, "p@55wOrd");

await EnsureUserAsync(new ApplicationUser
{
UserName = "mistral",
Email = "mistral-7B@email.com",
FirstName = "Mistral",
LastName = "7B",
DisplayName = "Mistral 7B",
EmailConfirmed = true,
ProfileUrl = "/img/profiles/mistral.svg",
ProfilePath = "/profiles/mi/mistral.svg",
Model = "mistral", //7B
}, "p@55wOrd");

await EnsureUserAsync(new ApplicationUser
{
UserName = "starcoder2-15b",
Email = "starcoder2-15b@email.com",
FirstName = "StarCoder2",
LastName = "15B",
DisplayName = "StarCoder2 15B",
EmailConfirmed = true,
ProfileUrl = "/img/profiles/starcoder2-15b.png",
ProfilePath = "/profiles/st/starcoder2-15b.png",
Model = "starcoder2:15b", //16B
}, "p@55wOrd");

await EnsureUserAsync(new ApplicationUser
{
UserName = "mixtral",
Email = "mixtral-8x7b@email.com",
FirstName = "Mixtral",
LastName = "8x7B",
DisplayName = "Mixtral 8x7B",
EmailConfirmed = true,
ProfileUrl = "/img/profiles/mixtral.jpg",
ProfilePath = "/profiles/mi/mixtral.jpg",
Model = "mixtral", //47B
}, "p@55wOrd");
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ protected override void Up(MigrationBuilder migrationBuilder)
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
FirstName = table.Column<string>(type: "TEXT", nullable: true),
LastName = table.Column<string>(type: "TEXT", nullable: true),
ProfileUrl = table.Column<string>(type: "TEXT", nullable: true),
DisplayName = table.Column<string>(type: "TEXT", nullable: true),
ProfilePath = table.Column<string>(type: "TEXT", nullable: true),
Model = table.Column<string>(type: "TEXT", nullable: true),
UserName = table.Column<string>(type: "TEXT", maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(type: "TEXT", maxLength: 256, nullable: true),
Expand Down
11 changes: 4 additions & 7 deletions MyApp/Migrations/ApplicationDbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,16 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.Property<string>("DisplayName")
.HasColumnType("TEXT");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<bool>("EmailConfirmed")
.HasColumnType("INTEGER");
b.Property<string>("FirstName")
.HasColumnType("TEXT");
b.Property<string>("LastName")
.HasColumnType("TEXT");
b.Property<bool>("LockoutEnabled")
.HasColumnType("INTEGER");
Expand All @@ -196,7 +193,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("INTEGER");
b.Property<string>("ProfileUrl")
b.Property<string>("ProfilePath")
.HasColumnType("TEXT");
b.Property<string>("SecurityStamp")
Expand Down

0 comments on commit 49ec9ee

Please sign in to comment.