mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
feat: totp 2fa; httpcontext extension for jwtuser; asp.net data protection; prevent banned users from certain actions; account deletion requires 2fa if enabled; making users admins requires 2fa if enabled; httpcontext extension to get ip; enhance user store
refactor: organize dtos by domain; verification providers use verification context; move ip parsing into http context extensions chore: clean code
This commit is contained in:
@@ -8,6 +8,7 @@ namespace SharpbinV3.Server.Data
|
||||
public DbSet<User> Users => Set<User>();
|
||||
public DbSet<Paste> Pastes => Set<Paste>();
|
||||
public DbSet<RefreshToken> RefreshTokens => Set<RefreshToken>();
|
||||
public DbSet<UserTotp> UserTotps => Set<UserTotp>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
@@ -24,6 +25,12 @@ namespace SharpbinV3.Server.Data
|
||||
.WithMany(u => u.RefreshTokens)
|
||||
.HasForeignKey(r => r.UserUUID)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<UserTotp>()
|
||||
.HasOne(t => t.User)
|
||||
.WithOne(u => u.Totp)
|
||||
.HasForeignKey<UserTotp>(t => t.UserUUID)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,5 +21,6 @@ namespace SharpbinV3.Server.Data.Entities
|
||||
public int Visibility { get; set; } = 0; // 0 = public, 1 = unlisted, 2 = private
|
||||
public List<Paste> Pastes { get; set; } = [];
|
||||
public List<RefreshToken> RefreshTokens { get; set; } = [];
|
||||
public UserTotp? Totp { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SharpbinV3.Server.Data.Entities
|
||||
{
|
||||
public class UserTotp
|
||||
{
|
||||
[Key]
|
||||
public Guid UserUUID { get; set; }
|
||||
public byte[] EncryptedSecret { get; set; } = null!;
|
||||
public long CreatedAt { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||
public User User { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user