diff --git a/README.md b/README.md index f05599c..098b9c3 100644 --- a/README.md +++ b/README.md @@ -73,5 +73,5 @@ sudo cp -a src/isnd/bin/Release/net10.0/publish/* /srv/www/isnd sudo systemctl start isnd # MAJ du client sudo cp -a src/isn/bin/Release/net10.0/* /usr/local/lib/isn -sudo chown -R root.root /usr/local/lib/isn +sudo chown -R root:root /usr/local/lib/isn ```` diff --git a/src/isnd/Controllers/AccountController.cs b/src/isnd/Controllers/AccountController.cs index e367166..ac7d908 100644 --- a/src/isnd/Controllers/AccountController.cs +++ b/src/isnd/Controllers/AccountController.cs @@ -240,10 +240,10 @@ namespace isnd.Controllers [Authorize] public async Task GetAdminrole() { - string username = User.FindFirstValue(ClaimTypes.NameIdentifier); - if (_startupAdminList.Users.Contains(username)) + string userEmail = User.FindFirstValue(ClaimTypes.Email); + if (_startupAdminList.Users.Contains(userEmail)) { - var user = await _userManager.FindByNameAsync(username); + var user = await _userManager.FindByEmailAsync(userEmail); var roles = await _userManager.GetRolesAsync(user); if (!roles.Contains(IsndConstants.AdministratorRoleName)) { diff --git a/src/isnd/Entities/SmtpSettings.cs b/src/isnd/Entities/SmtpSettings.cs index 5a4a861..3d2ae1d 100644 --- a/src/isnd/Entities/SmtpSettings.cs +++ b/src/isnd/Entities/SmtpSettings.cs @@ -2,11 +2,30 @@ namespace isnd.Entities { public class SmtpSettings { - public string Server {get; set;} + /** + * The SMTP server host. + */ + public string Host {get; set;} + + /** + * The SMTP server port. + */ public int Port {get; set;} + /** + * The name of the sender. + */ public string SenderName {get; set;} - public string SenderEMail {get; set;} + /** + * The email address of the sender. + */ + public string SenderEmail {get; set;} + /** + * The username for SMTP authentication. + */ public string UserName {get; set;} + /** + * The password for SMTP authentication. + */ public string Password {get; set;} } } \ No newline at end of file diff --git a/src/isnd/Migrations/20260705174847_net10.Designer.cs b/src/isnd/Migrations/20260705174847_net10.Designer.cs new file mode 100644 index 0000000..75e320c --- /dev/null +++ b/src/isnd/Migrations/20260705174847_net10.Designer.cs @@ -0,0 +1,458 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using isnd.Data; + +#nullable disable + +namespace isndhost.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20260705174847_net10")] + partial class net10 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("CreationDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ValidityPeriodInDays") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("ApiKeys"); + }); + + modelBuilder.Entity("isnd.Data.ApplicationUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FullName") + .HasColumnType("text"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("isnd.Data.PackageVersion", b => + { + b.Property("FullString") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("CommitNId") + .HasColumnType("bigint"); + + b.Property("IsPrerelease") + .HasColumnType("boolean"); + + b.Property("Major") + .HasColumnType("integer"); + + b.Property("Minor") + .HasColumnType("integer"); + + b.Property("PackageId") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("Patch") + .HasColumnType("integer"); + + b.Property("Revision") + .HasColumnType("integer"); + + b.Property("Type") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("FullString"); + + b.HasIndex("CommitNId"); + + b.HasIndex("PackageId"); + + b.ToTable("PackageVersions"); + }); + + modelBuilder.Entity("isnd.Data.Packages.Commit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("integer"); + + b.Property("TimeStamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Commits"); + }); + + modelBuilder.Entity("isnd.Data.Packages.Package", b => + { + b.Property("Id") + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("CommitNId") + .HasColumnType("bigint"); + + b.Property("CommitTimeStamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Public") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("CommitNId"); + + b.HasIndex("OwnerId"); + + b.ToTable("Packages"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("isnd.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("isnd.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("isnd.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("isnd.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b => + { + b.HasOne("isnd.Data.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("isnd.Data.PackageVersion", b => + { + b.HasOne("isnd.Data.Packages.Commit", "LatestCommit") + .WithMany("Versions") + .HasForeignKey("CommitNId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("isnd.Data.Packages.Package", "Package") + .WithMany("Versions") + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LatestCommit"); + + b.Navigation("Package"); + }); + + modelBuilder.Entity("isnd.Data.Packages.Package", b => + { + b.HasOne("isnd.Data.Packages.Commit", "LatestVersion") + .WithMany() + .HasForeignKey("CommitNId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("isnd.Data.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LatestVersion"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("isnd.Data.Packages.Commit", b => + { + b.Navigation("Versions"); + }); + + modelBuilder.Entity("isnd.Data.Packages.Package", b => + { + b.Navigation("Versions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/isnd/Migrations/20260705174847_net10.cs b/src/isnd/Migrations/20260705174847_net10.cs new file mode 100644 index 0000000..56789db --- /dev/null +++ b/src/isnd/Migrations/20260705174847_net10.cs @@ -0,0 +1,79 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace isndhost.Migrations +{ + /// + public partial class net10 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Id", + table: "Commits", + type: "bigint", + nullable: false, + oldClrType: typeof(long), + oldType: "bigint") + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) + .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); + + migrationBuilder.AlterColumn( + name: "Id", + table: "AspNetUserClaims", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer") + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) + .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); + + migrationBuilder.AlterColumn( + name: "Id", + table: "AspNetRoleClaims", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer") + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) + .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Id", + table: "Commits", + type: "bigint", + nullable: false, + oldClrType: typeof(long), + oldType: "bigint") + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + migrationBuilder.AlterColumn( + name: "Id", + table: "AspNetUserClaims", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer") + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + + migrationBuilder.AlterColumn( + name: "Id", + table: "AspNetRoleClaims", + type: "integer", + nullable: false, + oldClrType: typeof(int), + oldType: "integer") + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); + } + } +} diff --git a/src/isnd/Migrations/ApplicationDbContextModelSnapshot.cs b/src/isnd/Migrations/ApplicationDbContextModelSnapshot.cs index 7d8c883..1dba50c 100644 --- a/src/isnd/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/isnd/Migrations/ApplicationDbContextModelSnapshot.cs @@ -6,6 +6,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using isnd.Data; +#nullable disable + namespace isndhost.Migrations { [DbContext(typeof(ApplicationDbContext))] @@ -15,23 +17,161 @@ namespace isndhost.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) - .HasAnnotation("ProductVersion", "2.1.14-servicing-32113") + .HasAnnotation("ProductVersion", "10.0.9") .HasAnnotation("Relational:MaxIdentifierLength", 63); + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b => { b.Property("Id") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("text"); - b.Property("CreationDate"); + b.Property("CreationDate") + .HasColumnType("timestamp with time zone"); - b.Property("Name"); + b.Property("Name") + .HasColumnType("text"); b.Property("UserId") - .IsRequired(); + .IsRequired() + .HasColumnType("text"); - b.Property("ValidityPeriodInDays"); + b.Property("ValidityPeriodInDays") + .HasColumnType("integer"); b.HasKey("Id"); @@ -43,120 +183,102 @@ namespace isndhost.Migrations modelBuilder.Entity("isnd.Data.ApplicationUser", b => { b.Property("Id") - .ValueGeneratedOnAdd(); + .HasColumnType("text"); - b.Property("AccessFailedCount"); + b.Property("AccessFailedCount") + .HasColumnType("integer"); b.Property("ConcurrencyStamp") - .IsConcurrencyToken(); + .IsConcurrencyToken() + .HasColumnType("text"); b.Property("Email") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("character varying(256)"); - b.Property("EmailConfirmed"); + b.Property("EmailConfirmed") + .HasColumnType("boolean"); - b.Property("FullName"); + b.Property("FullName") + .HasColumnType("text"); - b.Property("LockoutEnabled"); + b.Property("LockoutEnabled") + .HasColumnType("boolean"); - b.Property("LockoutEnd"); + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); b.Property("NormalizedEmail") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("character varying(256)"); b.Property("NormalizedUserName") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("character varying(256)"); - b.Property("PasswordHash"); + b.Property("PasswordHash") + .HasColumnType("text"); - b.Property("PhoneNumber"); + b.Property("PhoneNumber") + .HasColumnType("text"); - b.Property("PhoneNumberConfirmed"); + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); - b.Property("SecurityStamp"); + b.Property("SecurityStamp") + .HasColumnType("text"); - b.Property("TwoFactorEnabled"); + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); b.Property("UserName") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("character varying(256)"); b.HasKey("Id"); b.HasIndex("NormalizedEmail") - .HasName("EmailIndex"); + .HasDatabaseName("EmailIndex"); b.HasIndex("NormalizedUserName") .IsUnique() - .HasName("UserNameIndex"); + .HasDatabaseName("UserNameIndex"); - b.ToTable("AspNetUsers"); - }); - - modelBuilder.Entity("isnd.Data.Packages.Commit", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Action"); - - b.Property("TimeStamp"); - - b.HasKey("Id"); - - b.ToTable("Commits"); - }); - - modelBuilder.Entity("isnd.Data.Packages.Package", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(1024); - - b.Property("CommitNId"); - - b.Property("CommitTimeStamp"); - - b.Property("Description") - .HasMaxLength(1024); - - b.Property("OwnerId") - .IsRequired(); - - b.Property("Public"); - - b.HasKey("Id"); - - b.HasIndex("CommitNId"); - - b.HasIndex("OwnerId"); - - b.ToTable("Packages"); + b.ToTable("AspNetUsers", (string)null); }); modelBuilder.Entity("isnd.Data.PackageVersion", b => { b.Property("FullString") - .ValueGeneratedOnAdd() - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("character varying(256)"); - b.Property("CommitNId"); + b.Property("CommitNId") + .HasColumnType("bigint"); - b.Property("IsPrerelease"); + b.Property("IsPrerelease") + .HasColumnType("boolean"); - b.Property("Major"); + b.Property("Major") + .HasColumnType("integer"); - b.Property("Minor"); + b.Property("Minor") + .HasColumnType("integer"); b.Property("PackageId") .IsRequired() - .HasMaxLength(1024); + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); - b.Property("Patch"); + b.Property("Patch") + .HasColumnType("integer"); - b.Property("Revision"); + b.Property("Revision") + .HasColumnType("integer"); b.Property("Type") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("character varying(256)"); b.HasKey("FullString"); @@ -167,111 +289,106 @@ namespace isndhost.Migrations b.ToTable("PackageVersions"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + modelBuilder.Entity("isnd.Data.Packages.Commit", b => { - b.Property("Id") - .ValueGeneratedOnAdd(); + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); - b.Property("ConcurrencyStamp") - .IsConcurrencyToken(); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("Name") - .HasMaxLength(256); + b.Property("Action") + .HasColumnType("integer"); - b.Property("NormalizedName") - .HasMaxLength(256); + b.Property("TimeStamp") + .HasColumnType("timestamp with time zone"); b.HasKey("Id"); - b.HasIndex("NormalizedName") - .IsUnique() - .HasName("RoleNameIndex"); + b.ToTable("Commits"); + }); - b.ToTable("AspNetRoles"); + modelBuilder.Entity("isnd.Data.Packages.Package", b => + { + b.Property("Id") + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("CommitNId") + .HasColumnType("bigint"); + + b.Property("CommitTimeStamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Public") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("CommitNId"); + + b.HasIndex("OwnerId"); + + b.ToTable("Packages"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ClaimType"); - - b.Property("ClaimValue"); - - b.Property("RoleId") + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ClaimType"); - - b.Property("ClaimValue"); - - b.Property("UserId") + b.HasOne("isnd.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { - b.Property("LoginProvider"); - - b.Property("ProviderKey"); - - b.Property("ProviderDisplayName"); - - b.Property("UserId") + b.HasOne("isnd.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => { - b.Property("UserId"); + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); - b.Property("RoleId"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles"); + b.HasOne("isnd.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { - b.Property("UserId"); - - b.Property("LoginProvider"); - - b.Property("Name"); - - b.Property("Value"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens"); + b.HasOne("isnd.Data.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b => @@ -279,20 +396,10 @@ namespace isndhost.Migrations b.HasOne("isnd.Data.ApplicationUser", "User") .WithMany() .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); - modelBuilder.Entity("isnd.Data.Packages.Package", b => - { - b.HasOne("isnd.Data.Packages.Commit", "LatestVersion") - .WithMany() - .HasForeignKey("CommitNId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("isnd.Data.ApplicationUser", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade); + b.Navigation("User"); }); modelBuilder.Entity("isnd.Data.PackageVersion", b => @@ -300,57 +407,47 @@ namespace isndhost.Migrations b.HasOne("isnd.Data.Packages.Commit", "LatestCommit") .WithMany("Versions") .HasForeignKey("CommitNId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("isnd.Data.Packages.Package", "Package") .WithMany("Versions") .HasForeignKey("PackageId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LatestCommit"); + + b.Navigation("Package"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + modelBuilder.Entity("isnd.Data.Packages.Package", b => { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") + b.HasOne("isnd.Data.Packages.Commit", "LatestVersion") .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade); + .HasForeignKey("CommitNId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("isnd.Data.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LatestVersion"); + + b.Navigation("Owner"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + modelBuilder.Entity("isnd.Data.Packages.Commit", b => { - b.HasOne("isnd.Data.ApplicationUser") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); + b.Navigation("Versions"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + modelBuilder.Entity("isnd.Data.Packages.Package", b => { - b.HasOne("isnd.Data.ApplicationUser") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("isnd.Data.ApplicationUser") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("isnd.Data.ApplicationUser") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); + b.Navigation("Versions"); }); #pragma warning restore 612, 618 } diff --git a/src/isnd/Services/EmailSender.cs b/src/isnd/Services/EmailSender.cs index 31b85e7..7f3d1fd 100644 --- a/src/isnd/Services/EmailSender.cs +++ b/src/isnd/Services/EmailSender.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Identity.UI.Services; using Microsoft.Extensions.Options; using Microsoft.AspNetCore.Hosting; using MailKit.Net.Smtp; +using MailKit.Security; using MimeKit; using System; @@ -36,14 +37,26 @@ namespace isnd.Services { try { var message = new MimeMessage(); - message.From.Add(new MailboxAddress(Options.SenderName, Options.SenderEMail)); - message.To.Add(new MailboxAddress(name??email, email)); + message.From.Add(new MailboxAddress(Options.SenderName, Options.SenderEmail)); + message.To.Add(new MailboxAddress(name ?? email, email)); message.Body = new TextPart("html") { Text = body }; using (var client = new SmtpClient()) { - client.ServerCertificateValidationCallback = (s,c,h,e)=>true; - await client.ConnectAsync(Options.Server); - await client.AuthenticateAsync(Options.UserName, Options.Password); + client.ServerCertificateValidationCallback = (s,c,h,e) => true; + if (Options.Port > 0) + { + await client.ConnectAsync(Options.Host, Options.Port, SecureSocketOptions.Auto); + } + else + { + await client.ConnectAsync(Options.Host); + } + + if (!string.IsNullOrWhiteSpace(Options.UserName)) + { + await client.AuthenticateAsync(Options.UserName, Options.Password); + } + await client.SendAsync(message); await client.DisconnectAsync(true); } diff --git a/src/isnd/appsettings.json b/src/isnd/appsettings.json index ba98409..06ba611 100644 --- a/src/isnd/appsettings.json +++ b/src/isnd/appsettings.json @@ -16,7 +16,7 @@ }, "AllowedHosts": "*", "Smtp": { - "Server": "", + "Host": "", "Port": 25, "SenderName": "", "SenderEmail": ""