mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
Some small refresh token work #865
This commit is contained in:
parent
8b3c57431c
commit
24e424f004
11 changed files with 158 additions and 52 deletions
|
@ -29,5 +29,6 @@ namespace Ombi.Store.Context
|
|||
DbSet<ChildRequests> ChildRequests { get; set; }
|
||||
DbSet<MovieIssues> MovieIssues { get; set; }
|
||||
DbSet<TvIssues> TvIssues { get; set; }
|
||||
DbSet<Tokens> Tokens { get; set; }
|
||||
}
|
||||
}
|
|
@ -35,6 +35,7 @@ namespace Ombi.Store.Context
|
|||
public DbSet<TvIssues> TvIssues { get; set; }
|
||||
|
||||
public DbSet<Audit> Audit { get; set; }
|
||||
public DbSet<Tokens> Tokens { get; set; }
|
||||
|
||||
public DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||
|
||||
|
|
14
src/Ombi.Store/Entities/Tokens.cs
Normal file
14
src/Ombi.Store/Entities/Tokens.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Ombi.Store.Entities
|
||||
{
|
||||
public class Tokens : Entity
|
||||
{
|
||||
public string Token { get; set; }
|
||||
public string UserId { get; set; }
|
||||
|
||||
|
||||
[ForeignKey(nameof(UserId))]
|
||||
public OmbiUser User { get; set; }
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ using Ombi.Helpers;
|
|||
namespace Ombi.Store.Migrations
|
||||
{
|
||||
[DbContext(typeof(OmbiContext))]
|
||||
[Migration("20170801143617_Inital")]
|
||||
[Migration("20170811145836_Inital")]
|
||||
partial class Inital
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
|
@ -449,6 +449,22 @@ namespace Ombi.Store.Migrations
|
|||
b.ToTable("TvRequests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.Tokens", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Token");
|
||||
|
||||
b.Property<string>("UserId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Tokens");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
|
@ -581,6 +597,13 @@ namespace Ombi.Store.Migrations
|
|||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.Tokens", b =>
|
||||
{
|
||||
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b =>
|
||||
{
|
||||
b.HasOne("Ombi.Store.Repository.Requests.SeasonRequests", "Season")
|
|
@ -296,6 +296,26 @@ namespace Ombi.Store.Migrations
|
|||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Tokens",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Token = table.Column<string>(nullable: true),
|
||||
UserId = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Tokens", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Tokens_AspNetUsers_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PlexSeasonsContent",
|
||||
columns: table => new
|
||||
|
@ -531,6 +551,11 @@ namespace Ombi.Store.Migrations
|
|||
table: "TvIssues",
|
||||
column: "TvId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Tokens_UserId",
|
||||
table: "Tokens",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EpisodeRequests_SeasonId",
|
||||
table: "EpisodeRequests",
|
||||
|
@ -583,6 +608,9 @@ namespace Ombi.Store.Migrations
|
|||
migrationBuilder.DropTable(
|
||||
name: "TvIssues");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Tokens");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "EpisodeRequests");
|
||||
|
|
@ -448,6 +448,22 @@ namespace Ombi.Store.Migrations
|
|||
b.ToTable("TvRequests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.Tokens", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Token");
|
||||
|
||||
b.Property<string>("UserId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Tokens");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
|
@ -580,6 +596,13 @@ namespace Ombi.Store.Migrations
|
|||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.Tokens", b =>
|
||||
{
|
||||
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b =>
|
||||
{
|
||||
b.HasOne("Ombi.Store.Repository.Requests.SeasonRequests", "Season")
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
//public interface ITokenRepository
|
||||
//{
|
||||
// Task CreateToken(EmailTokens token);
|
||||
// Task<EmailTokens> GetToken(Guid tokenId);
|
||||
//}
|
||||
public interface ITokenRepository
|
||||
{
|
||||
Task CreateToken(Tokens token);
|
||||
IQueryable<Tokens> GetToken(string tokenId);
|
||||
}
|
||||
}
|
|
@ -2,29 +2,29 @@
|
|||
using Ombi.Store.Context;
|
||||
using Ombi.Store.Entities;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
//public class TokenRepository : ITokenRepository
|
||||
//{
|
||||
// public TokenRepository(IOmbiContext db)
|
||||
// {
|
||||
// Db = db;
|
||||
// }
|
||||
public class TokenRepository : ITokenRepository
|
||||
{
|
||||
public TokenRepository(IOmbiContext db)
|
||||
{
|
||||
Db = db;
|
||||
}
|
||||
|
||||
// private IOmbiContext Db { get; }
|
||||
private IOmbiContext Db { get; }
|
||||
|
||||
// public async Task CreateToken(EmailTokens token)
|
||||
// {
|
||||
// token.Token = Guid.NewGuid();
|
||||
// await Db.EmailTokens.AddAsync(token);
|
||||
// await Db.SaveChangesAsync();
|
||||
// }
|
||||
public async Task CreateToken(Tokens token)
|
||||
{
|
||||
await Db.Tokens.AddAsync(token);
|
||||
await Db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
// public async Task<EmailTokens> GetToken(Guid tokenId)
|
||||
// {
|
||||
// return await Db.EmailTokens.FirstOrDefaultAsync(x => x.Token == tokenId);
|
||||
// }
|
||||
//}
|
||||
public IQueryable<Tokens> GetToken(string tokenId)
|
||||
{
|
||||
return Db.Tokens.Where(x => x.Token == tokenId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue