Fixed the issue where we were not validting the correct token when resetting the password #865

Removed the old user (Well commented it out for now)
pull/1488/head
Jamie.Rees 7 years ago
parent 818acd6452
commit 6c3523b21e

@ -7,8 +7,10 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Security.Claims;
using System.Security.Principal;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Ombi.Core.Engine.Interfaces;
@ -21,7 +23,7 @@ namespace Ombi.Core.Engine
public class MovieRequestEngine : BaseMediaEngine, IMovieRequestEngine
{
public MovieRequestEngine(IMovieDbApi movieApi, IRequestServiceMain requestService, IPrincipal user,
INotificationHelper helper, IRuleEvaluator r, IMovieSender sender, ILogger<MovieRequestEngine> log, IUserIdentityManager manager) : base(user, requestService, r)
INotificationHelper helper, IRuleEvaluator r, IMovieSender sender, ILogger<MovieRequestEngine> log, UserManager<OmbiUser> manager) : base(user, requestService, r)
{
MovieApi = movieApi;
NotificationHelper = helper;
@ -34,7 +36,7 @@ namespace Ombi.Core.Engine
private INotificationHelper NotificationHelper { get; }
private IMovieSender Sender { get; }
private ILogger<MovieRequestEngine> Logger { get; }
private IUserIdentityManager UserManager { get; }
private UserManager<OmbiUser> UserManager { get; }
/// <summary>
/// Requests the movie.
@ -56,7 +58,7 @@ namespace Ombi.Core.Engine
var fullMovieName =
$"{movieInfo.Title}{(!string.IsNullOrEmpty(movieInfo.ReleaseDate) ? $" ({DateTime.Parse(movieInfo.ReleaseDate).Year})" : string.Empty)}";
var userDetails = await UserManager.GetUser(User.Identity.Name);
var userDetails = await UserManager.GetUserAsync(new ClaimsPrincipal(User));
var requestModel = new MovieRequests
{

@ -8,8 +8,10 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Security.Claims;
using System.Security.Principal;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Ombi.Core.Engine.Interfaces;
using Ombi.Core.Helpers;
@ -25,7 +27,7 @@ namespace Ombi.Core.Engine
{
public TvRequestEngine(ITvMazeApi tvApi, IRequestServiceMain requestService, IPrincipal user,
INotificationHelper helper, IMapper map,
IRuleEvaluator rule, IUserIdentityManager manager,
IRuleEvaluator rule, UserManager<OmbiUser> manager,
ITvSender sender) : base(user, requestService, rule)
{
TvApi = tvApi;
@ -38,12 +40,12 @@ namespace Ombi.Core.Engine
private INotificationHelper NotificationHelper { get; }
private ITvMazeApi TvApi { get; }
private IMapper Mapper { get; }
private IUserIdentityManager UserManager { get; }
private UserManager<OmbiUser> UserManager { get; }
private ITvSender TvSender {get;}
public async Task<RequestEngineResult> RequestTvShow(SearchTvShowViewModel tv)
{
var user = await UserManager.GetUser(User.Identity.Name);
var user = await UserManager.GetUserAsync(new ClaimsPrincipal(User));
var tvBuilder = new TvShowRequestBuilder(TvApi);
(await tvBuilder

@ -43,7 +43,7 @@ namespace Ombi.Core.Helpers
return this;
}
public TvShowRequestBuilder CreateChild(SearchTvShowViewModel model, int userId)
public TvShowRequestBuilder CreateChild(SearchTvShowViewModel model, string userId)
{
ChildRequest = new ChildRequests
{

@ -76,14 +76,14 @@ namespace Ombi.DependencyInjection
services.AddScoped<IOmbiContext, OmbiContext>();
services.AddTransient<ISettingsRepository, SettingsJsonRepository>();
services.AddTransient<IUserRepository, UserRepository>();
//services.AddTransient<IUserRepository, UserRepository>();
services.AddTransient<ISettingsResolver, SettingsResolver>();
services.AddTransient<IPlexContentRepository, PlexContentRepository>();
services.AddTransient<INotificationTemplatesRepository, NotificationTemplatesRepository>();
services.AddTransient<ITvRequestRepository, TvRequestRepository>();
services.AddTransient<IMovieRequestRepository, MovieRequestRepository>();
services.AddTransient<ITokenRepository, TokenRepository>();
//services.AddTransient<ITokenRepository, TokenRepository>();
services.AddTransient(typeof(ISettingsService<>), typeof(SettingsService<>));
}
public static void RegisterServices(this IServiceCollection services)
@ -107,7 +107,6 @@ namespace Ombi.DependencyInjection
public static void RegisterIdentity(this IServiceCollection services)
{
services.AddTransient<IUserIdentityManager, UserIdentityManager>();
services.AddAuthorization(auth =>
{
auth.AddPolicy("Bearer", new AuthorizationPolicyBuilder()

@ -13,7 +13,7 @@ namespace Ombi.Mapping.Profiles
{
public OmbiProfile()
{
CreateMap<User, UserDto>().ReverseMap();
//CreateMap<User, UserDto>().ReverseMap();
CreateMap<Claim, ClaimCheckboxes>().ConvertUsing<ClaimsConverter>();

@ -10,7 +10,7 @@ namespace Ombi.Notifications
public void Setup(FullBaseRequest req)
{
RequestedUser = string.IsNullOrEmpty(req.RequestedUser.Alias)
? req.RequestedUser.Username
? req.RequestedUser.UserName
: req.RequestedUser.Alias;
Title = req.Title;
RequestedDate = req.RequestedDate.ToString("D");
@ -23,7 +23,7 @@ namespace Ombi.Notifications
public void Setup(ChildRequests req)
{
RequestedUser = string.IsNullOrEmpty(req.RequestedUser.Alias)
? req.RequestedUser.Username
? req.RequestedUser.UserName
: req.RequestedUser.Alias;
Title = req.ParentRequest.Title;
RequestedDate = req.RequestedDate.ToString("D");

@ -17,17 +17,16 @@ namespace Ombi.Store.Context
DbSet<PlexContent> PlexContent { get; set; }
DbSet<RadarrCache> RadarrCache { get; set; }
DatabaseFacade Database { get; }
DbSet<User> OldUsers { get; set; }
EntityEntry<T> Entry<T>(T entry) where T : class;
EntityEntry<TEntity> Attach<TEntity>(TEntity entity) where TEntity : class;
DbSet<TEntity> Set<TEntity>() where TEntity : class;
DbSet<NotificationTemplates> NotificationTemplates { get; set; }
void Seed();
DbSet<MovieRequests> MovieRequests { get; set; }
DbSet<TvRequests> TvRequests { get; set; }
DbSet<ChildRequests> ChildRequests { get; set; }
DbSet<MovieIssues> MovieIssues { get; set; }
DbSet<TvIssues> TvIssues { get; set; }
DbSet<EmailTokens> EmailTokens { get; set; }
}
}

@ -19,28 +19,20 @@ namespace Ombi.Store.Context
Database.Migrate();
// Add the notifcation templates
AddAllTemplates();
}
public DbSet<NotificationTemplates> NotificationTemplates { get; set; }
public DbSet<GlobalSettings> Settings { get; set; }
public DbSet<User> OldUsers { get; set; }
public DbSet<PlexContent> PlexContent { get; set; }
public DbSet<RadarrCache> RadarrCache { get; set; }
public DbSet<NotificationTemplates> NotificationTemplates { get; set; }
public DbSet<MovieRequests> MovieRequests { get; set; }
public DbSet<TvRequests> TvRequests { get; set; }
public DbSet<ChildRequests> ChildRequests { get; set; }
public DbSet<MovieIssues> MovieIssues { get; set; }
public DbSet<TvIssues> TvIssues { get; set; }
public DbSet<EmailTokens> EmailTokens { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@ -48,7 +40,7 @@ namespace Ombi.Store.Context
}
private void AddAllTemplates()
public void Seed()
{
// Check if templates exist
var templates = NotificationTemplates.ToList();

@ -1,18 +0,0 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ombi.Store.Entities
{
[Table("EmailTokens")]
public class EmailTokens : Entity
{
public Guid Token { get; set; }
public int UserId { get; set; }
public DateTime ValidUntil { get; set; }
public bool Used { get; set; }
public DateTime DateUsed { get; set; }
[ForeignKey(nameof(UserId))]
public User User { get; set; }
}
}

@ -10,13 +10,13 @@ namespace Ombi.Store.Entities.Requests
public bool Approved { get; set; }
public DateTime RequestedDate { get; set; }
public bool Available { get; set; }
public int RequestedUserId { get; set; }
public string RequestedUserId { get; set; }
public bool? Denied { get; set; }
public string DeniedReason { get; set; }
public RequestType RequestType { get; set; }
[ForeignKey(nameof(RequestedUserId))]
public User RequestedUser { get; set; }
public OmbiUser RequestedUser { get; set; }
[NotMapped]

@ -34,25 +34,25 @@ using Ombi.Helpers;
namespace Ombi.Store.Entities
{
public class User : Entity
{
public string Username { get; set; }
public string Alias { get; set; }
public string ClaimsSerialized { get; set; }
public string EmailAddress { get; set; }
public string Password { get; set; }
public byte[] Salt { get; set; }
public UserType UserType { get; set; }
//public class User : Entity
//{
// public string Username { get; set; }
// public string Alias { get; set; }
// public string ClaimsSerialized { get; set; }
// public string EmailAddress { get; set; }
// public string Password { get; set; }
// public byte[] Salt { get; set; }
// public UserType UserType { get; set; }
[NotMapped]
public string UserAlias => string.IsNullOrEmpty(Alias) ? Username : Alias;
// [NotMapped]
// public string UserAlias => string.IsNullOrEmpty(Alias) ? Username : Alias;
[NotMapped]
public List<Claim> Claims {
get => JsonConvert.DeserializeObject<List<Claim>>(ClaimsSerialized, new ClaimConverter());
set => ClaimsSerialized = JsonConvert.SerializeObject(value, new ClaimConverter());
}
}
// [NotMapped]
// public List<Claim> Claims {
// get => JsonConvert.DeserializeObject<List<Claim>>(ClaimsSerialized, new ClaimConverter());
// set => ClaimsSerialized = JsonConvert.SerializeObject(value, new ClaimConverter());
// }
//}
public enum UserType
{

@ -10,7 +10,7 @@ using Ombi.Store.Entities;
namespace Ombi.Store.Migrations
{
[DbContext(typeof(OmbiContext))]
[Migration("20170712080109_Initial")]
[Migration("20170719072204_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -125,28 +125,6 @@ namespace Ombi.Store.Migrations
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("Ombi.Store.Entities.EmailTokens", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("DateUsed");
b.Property<Guid>("Token");
b.Property<bool>("Used");
b.Property<int>("UserId");
b.Property<DateTime>("ValidUntil");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("EmailTokens");
});
modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b =>
{
b.Property<int>("Id")
@ -312,7 +290,7 @@ namespace Ombi.Store.Migrations
b.Property<DateTime>("RequestedDate");
b.Property<int>("RequestedUserId");
b.Property<string>("RequestedUserId");
b.Property<string>("Title");
@ -374,7 +352,7 @@ namespace Ombi.Store.Migrations
b.Property<DateTime>("RequestedDate");
b.Property<int>("RequestedUserId");
b.Property<string>("RequestedUserId");
b.Property<string>("Status");
@ -437,30 +415,6 @@ namespace Ombi.Store.Migrations
b.ToTable("TvRequests");
});
modelBuilder.Entity("Ombi.Store.Entities.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Alias");
b.Property<string>("ClaimsSerialized");
b.Property<string>("EmailAddress");
b.Property<string>("Password");
b.Property<byte[]>("Salt");
b.Property<int>("UserType");
b.Property<string>("Username");
b.HasKey("Id");
b.ToTable("OldUsers");
});
modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b =>
{
b.Property<int>("Id")
@ -542,14 +496,6 @@ namespace Ombi.Store.Migrations
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Ombi.Store.Entities.EmailTokens", b =>
{
b.HasOne("Ombi.Store.Entities.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b =>
{
b.HasOne("Ombi.Store.Entities.PlexContent")
@ -565,10 +511,9 @@ namespace Ombi.Store.Migrations
.HasForeignKey("ParentRequestId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Ombi.Store.Entities.User", "RequestedUser")
b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser")
.WithMany()
.HasForeignKey("RequestedUserId")
.OnDelete(DeleteBehavior.Cascade);
.HasForeignKey("RequestedUserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieIssues", b =>
@ -585,10 +530,9 @@ namespace Ombi.Store.Migrations
modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b =>
{
b.HasOne("Ombi.Store.Entities.User", "RequestedUser")
b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser")
.WithMany()
.HasForeignKey("RequestedUserId")
.OnDelete(DeleteBehavior.Cascade);
.HasForeignKey("RequestedUserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.TvIssues", b =>

@ -146,25 +146,6 @@ namespace Ombi.Store.Migrations
table.PrimaryKey("PK_TvRequests", x => x.Id);
});
migrationBuilder.CreateTable(
name: "OldUsers",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Alias = table.Column<string>(nullable: true),
ClaimsSerialized = table.Column<string>(nullable: true),
EmailAddress = table.Column<string>(nullable: true),
Password = table.Column<string>(nullable: true),
Salt = table.Column<byte[]>(nullable: true),
UserType = table.Column<int>(nullable: false),
Username = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_OldUsers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetRoleClaims",
columns: table => new
@ -252,46 +233,56 @@ namespace Ombi.Store.Migrations
});
migrationBuilder.CreateTable(
name: "PlexSeasonsContent",
name: "MovieRequests",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ParentKey = table.Column<int>(nullable: false),
PlexContentId = table.Column<int>(nullable: false),
SeasonKey = table.Column<int>(nullable: false),
SeasonNumber = table.Column<int>(nullable: false)
Approved = table.Column<bool>(nullable: false),
Available = table.Column<bool>(nullable: false),
Denied = table.Column<bool>(nullable: true),
DeniedReason = table.Column<string>(nullable: true),
ImdbId = table.Column<string>(nullable: true),
IssueId = table.Column<int>(nullable: true),
Overview = table.Column<string>(nullable: true),
PosterPath = table.Column<string>(nullable: true),
ReleaseDate = table.Column<DateTime>(nullable: false),
RequestType = table.Column<int>(nullable: false),
RequestedDate = table.Column<DateTime>(nullable: false),
RequestedUserId = table.Column<string>(nullable: true),
Status = table.Column<string>(nullable: true),
TheMovieDbId = table.Column<int>(nullable: false),
Title = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PlexSeasonsContent", x => x.Id);
table.PrimaryKey("PK_MovieRequests", x => x.Id);
table.ForeignKey(
name: "FK_PlexSeasonsContent_PlexContent_PlexContentId",
column: x => x.PlexContentId,
principalTable: "PlexContent",
name: "FK_MovieRequests_AspNetUsers_RequestedUserId",
column: x => x.RequestedUserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "EmailTokens",
name: "PlexSeasonsContent",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
DateUsed = table.Column<DateTime>(nullable: false),
Token = table.Column<Guid>(nullable: false),
Used = table.Column<bool>(nullable: false),
UserId = table.Column<int>(nullable: false),
ValidUntil = table.Column<DateTime>(nullable: false)
ParentKey = table.Column<int>(nullable: false),
PlexContentId = table.Column<int>(nullable: false),
SeasonKey = table.Column<int>(nullable: false),
SeasonNumber = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EmailTokens", x => x.Id);
table.PrimaryKey("PK_PlexSeasonsContent", x => x.Id);
table.ForeignKey(
name: "FK_EmailTokens_OldUsers_UserId",
column: x => x.UserId,
principalTable: "OldUsers",
name: "FK_PlexSeasonsContent_PlexContent_PlexContentId",
column: x => x.PlexContentId,
principalTable: "PlexContent",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
@ -310,7 +301,7 @@ namespace Ombi.Store.Migrations
ParentRequestId = table.Column<int>(nullable: false),
RequestType = table.Column<int>(nullable: false),
RequestedDate = table.Column<DateTime>(nullable: false),
RequestedUserId = table.Column<int>(nullable: false),
RequestedUserId = table.Column<string>(nullable: true),
Title = table.Column<string>(nullable: true)
},
constraints: table =>
@ -323,42 +314,37 @@ namespace Ombi.Store.Migrations
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ChildRequests_OldUsers_RequestedUserId",
name: "FK_ChildRequests_AspNetUsers_RequestedUserId",
column: x => x.RequestedUserId,
principalTable: "OldUsers",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "MovieRequests",
name: "MovieIssues",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Approved = table.Column<bool>(nullable: false),
Available = table.Column<bool>(nullable: false),
Denied = table.Column<bool>(nullable: true),
DeniedReason = table.Column<string>(nullable: true),
ImdbId = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true),
IssueId = table.Column<int>(nullable: true),
Overview = table.Column<string>(nullable: true),
PosterPath = table.Column<string>(nullable: true),
ReleaseDate = table.Column<DateTime>(nullable: false),
RequestType = table.Column<int>(nullable: false),
RequestedDate = table.Column<DateTime>(nullable: false),
RequestedUserId = table.Column<int>(nullable: false),
Status = table.Column<string>(nullable: true),
TheMovieDbId = table.Column<int>(nullable: false),
Title = table.Column<string>(nullable: true)
MovieId = table.Column<int>(nullable: false),
Subect = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_MovieRequests", x => x.Id);
table.PrimaryKey("PK_MovieIssues", x => x.Id);
table.ForeignKey(
name: "FK_MovieRequests_OldUsers_RequestedUserId",
column: x => x.RequestedUserId,
principalTable: "OldUsers",
name: "FK_MovieIssues_MovieRequests_IssueId",
column: x => x.IssueId,
principalTable: "MovieRequests",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_MovieIssues_MovieRequests_MovieId",
column: x => x.MovieId,
principalTable: "MovieRequests",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
@ -411,34 +397,6 @@ namespace Ombi.Store.Migrations
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "MovieIssues",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Description = table.Column<string>(nullable: true),
IssueId = table.Column<int>(nullable: true),
MovieId = table.Column<int>(nullable: false),
Subect = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_MovieIssues", x => x.Id);
table.ForeignKey(
name: "FK_MovieIssues_MovieRequests_IssueId",
column: x => x.IssueId,
principalTable: "MovieRequests",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_MovieIssues_MovieRequests_MovieId",
column: x => x.MovieId,
principalTable: "MovieRequests",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "EpisodeRequests",
columns: table => new
@ -491,11 +449,6 @@ namespace Ombi.Store.Migrations
table: "AspNetUserRoles",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "IX_EmailTokens_UserId",
table: "EmailTokens",
column: "UserId");
migrationBuilder.CreateIndex(
name: "EmailIndex",
table: "AspNetUsers",
@ -575,9 +528,6 @@ namespace Ombi.Store.Migrations
migrationBuilder.DropTable(
name: "AspNetUserTokens");
migrationBuilder.DropTable(
name: "EmailTokens");
migrationBuilder.DropTable(
name: "GlobalSettings");
@ -602,9 +552,6 @@ namespace Ombi.Store.Migrations
migrationBuilder.DropTable(
name: "AspNetRoles");
migrationBuilder.DropTable(
name: "AspNetUsers");
migrationBuilder.DropTable(
name: "PlexContent");
@ -621,7 +568,7 @@ namespace Ombi.Store.Migrations
name: "TvRequests");
migrationBuilder.DropTable(
name: "OldUsers");
name: "AspNetUsers");
}
}
}

@ -124,28 +124,6 @@ namespace Ombi.Store.Migrations
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("Ombi.Store.Entities.EmailTokens", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("DateUsed");
b.Property<Guid>("Token");
b.Property<bool>("Used");
b.Property<int>("UserId");
b.Property<DateTime>("ValidUntil");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("EmailTokens");
});
modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b =>
{
b.Property<int>("Id")
@ -311,7 +289,7 @@ namespace Ombi.Store.Migrations
b.Property<DateTime>("RequestedDate");
b.Property<int>("RequestedUserId");
b.Property<string>("RequestedUserId");
b.Property<string>("Title");
@ -373,7 +351,7 @@ namespace Ombi.Store.Migrations
b.Property<DateTime>("RequestedDate");
b.Property<int>("RequestedUserId");
b.Property<string>("RequestedUserId");
b.Property<string>("Status");
@ -436,30 +414,6 @@ namespace Ombi.Store.Migrations
b.ToTable("TvRequests");
});
modelBuilder.Entity("Ombi.Store.Entities.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Alias");
b.Property<string>("ClaimsSerialized");
b.Property<string>("EmailAddress");
b.Property<string>("Password");
b.Property<byte[]>("Salt");
b.Property<int>("UserType");
b.Property<string>("Username");
b.HasKey("Id");
b.ToTable("OldUsers");
});
modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b =>
{
b.Property<int>("Id")
@ -541,14 +495,6 @@ namespace Ombi.Store.Migrations
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Ombi.Store.Entities.EmailTokens", b =>
{
b.HasOne("Ombi.Store.Entities.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b =>
{
b.HasOne("Ombi.Store.Entities.PlexContent")
@ -564,10 +510,9 @@ namespace Ombi.Store.Migrations
.HasForeignKey("ParentRequestId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Ombi.Store.Entities.User", "RequestedUser")
b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser")
.WithMany()
.HasForeignKey("RequestedUserId")
.OnDelete(DeleteBehavior.Cascade);
.HasForeignKey("RequestedUserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieIssues", b =>
@ -584,10 +529,9 @@ namespace Ombi.Store.Migrations
modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b =>
{
b.HasOne("Ombi.Store.Entities.User", "RequestedUser")
b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser")
.WithMany()
.HasForeignKey("RequestedUserId")
.OnDelete(DeleteBehavior.Cascade);
.HasForeignKey("RequestedUserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.TvIssues", b =>

@ -4,9 +4,9 @@ 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(EmailTokens token);
// Task<EmailTokens> GetToken(Guid tokenId);
//}
}

@ -4,13 +4,13 @@ using Ombi.Store.Entities;
namespace Ombi.Store.Repository
{
public interface IUserRepository
{
Task CreateUser(User user);
Task<User> GetUser(string username);
Task<IEnumerable<User>> GetUsers();
Task DeleteUser(User user);
Task<User> UpdateUser(User user);
Task<User> GetUser(int userId);
}
//public interface IUserRepository
//{
// Task CreateUser(User user);
// Task<User> GetUser(string username);
// Task<IEnumerable<User>> GetUsers();
// Task DeleteUser(User user);
// Task<User> UpdateUser(User user);
// Task<User> GetUser(int userId);
//}
}

@ -6,25 +6,25 @@ 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(EmailTokens token)
// {
// token.Token = Guid.NewGuid();
// await Db.EmailTokens.AddAsync(token);
// await Db.SaveChangesAsync();
// }
public async Task<EmailTokens> GetToken(Guid tokenId)
{
return await Db.EmailTokens.FirstOrDefaultAsync(x => x.Token == tokenId);
}
}
// public async Task<EmailTokens> GetToken(Guid tokenId)
// {
// return await Db.EmailTokens.FirstOrDefaultAsync(x => x.Token == tokenId);
// }
//}
}

@ -34,53 +34,53 @@ using Ombi.Store.Entities;
namespace Ombi.Store.Repository
{
public class UserRepository : IUserRepository
{
public UserRepository(IOmbiContext ctx)
{
Db = ctx;
}
//public class UserRepository : IUserRepository
//{
// public UserRepository(IOmbiContext ctx)
// {
// Db = ctx;
// }
private IOmbiContext Db { get; }
// private IOmbiContext Db { get; }
public async Task<User> GetUser(string username)
{
var user = await Db.OldUsers.FirstOrDefaultAsync(x => x.Username.ToLower() == username.ToLower());
Db.Entry(user).Reload();
return user;
}
// public async Task<User> GetUser(string username)
// {
// var user = await Db.OldUsers.FirstOrDefaultAsync(x => x.Username.ToLower() == username.ToLower());
// Db.Entry(user).Reload();
// return user;
// }
public async Task<User> GetUser(int userId)
{
var user = await Db.OldUsers.FirstOrDefaultAsync(x => x.Id == userId);
Db.Entry(user).Reload();
return user;
}
// public async Task<User> GetUser(int userId)
// {
// var user = await Db.OldUsers.FirstOrDefaultAsync(x => x.Id == userId);
// Db.Entry(user).Reload();
// return user;
// }
public async Task CreateUser(User user)
{
Db.OldUsers.Add(user);
await Db.SaveChangesAsync();
}
// public async Task CreateUser(User user)
// {
// Db.OldUsers.Add(user);
// await Db.SaveChangesAsync();
// }
public async Task<IEnumerable<User>> GetUsers()
{
return await Db.OldUsers.ToListAsync();
}
// public async Task<IEnumerable<User>> GetUsers()
// {
// return await Db.OldUsers.ToListAsync();
// }
public async Task DeleteUser(User user)
{
Db.OldUsers.Remove(user);
await Db.SaveChangesAsync();
}
// public async Task DeleteUser(User user)
// {
// Db.OldUsers.Remove(user);
// await Db.SaveChangesAsync();
// }
public async Task<User> UpdateUser(User user)
{
Db.Entry(user).State = EntityState.Modified;
Db.Entry(user).Property(x => x.Salt).IsModified = false;
Db.Entry(user).Property(x => x.Password).IsModified = false;
await Db.SaveChangesAsync();
return user;
}
}
// public async Task<User> UpdateUser(User user)
// {
// Db.Entry(user).State = EntityState.Modified;
// Db.Entry(user).Property(x => x.Salt).IsModified = false;
// Db.Entry(user).Property(x => x.Password).IsModified = false;
// await Db.SaveChangesAsync();
// return user;
// }
//}
}

@ -435,7 +435,7 @@ namespace Ombi.Controllers
}
// We have the user
var token = await UserManager.GenerateEmailConfirmationTokenAsync(user);
var token = await UserManager.GeneratePasswordResetTokenAsync(user);
// We now need to email the user with this token
var emailSettings = await EmailSettings.GetSettingsAsync();
var customizationSettings = await CustomizationSettings.GetSettingsAsync();

@ -169,6 +169,7 @@ namespace Ombi
#endif
// Make sure you have memory cache available unless you're using another storage provider
services.AddMemoryCache();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -232,9 +233,9 @@ namespace Ombi
// Setup the scheduler
var jobSetup = (IJobSetup)app.ApplicationServices.GetService(typeof(IJobSetup));
var ctx = (IOmbiContext)app.ApplicationServices.GetService(typeof(IOmbiContext));
jobSetup.Setup();
//ConfigureAuth(app, (IOptions<TokenAuthenticationOptions>)app.ApplicationServices.GetService(typeof(IOptions<TokenAuthenticationOptions>)));
ctx.Seed();
var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".map"] = "application/octet-stream";

Loading…
Cancel
Save