mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-10 07:22:35 -07:00
Fixed #862
This commit is contained in:
parent
7081eac5bb
commit
d032cdfa54
3 changed files with 61 additions and 17 deletions
|
@ -73,29 +73,51 @@ namespace Ombi.Core
|
||||||
public RequestedModel CheckRequest(int providerId)
|
public RequestedModel CheckRequest(int providerId)
|
||||||
{
|
{
|
||||||
var blobs = Repo.GetAll();
|
var blobs = Repo.GetAll();
|
||||||
var blob = blobs.FirstOrDefault(x => x.ProviderId == providerId);
|
var blob = blobs.FirstOrDefault(x => x.ProviderId == providerId); if (blob == null)
|
||||||
return blob != null ? ByteConverterHelper.ReturnObject<RequestedModel>(blob.Content) : null;
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var model = ByteConverterHelper.ReturnObject<RequestedModel>(blob.Content);
|
||||||
|
model.Id = blob.Id;
|
||||||
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RequestedModel> CheckRequestAsync(int providerId)
|
public async Task<RequestedModel> CheckRequestAsync(int providerId)
|
||||||
{
|
{
|
||||||
var blobs = await Repo.GetAllAsync().ConfigureAwait(false);
|
var blobs = await Repo.GetAllAsync().ConfigureAwait(false);
|
||||||
var blob = blobs.FirstOrDefault(x => x.ProviderId == providerId);
|
var blob = blobs.FirstOrDefault(x => x.ProviderId == providerId); if (blob == null)
|
||||||
return blob != null ? ByteConverterHelper.ReturnObject<RequestedModel>(blob.Content) : null;
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var model = ByteConverterHelper.ReturnObject<RequestedModel>(blob.Content);
|
||||||
|
model.Id = blob.Id;
|
||||||
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RequestedModel CheckRequest(string musicId)
|
public RequestedModel CheckRequest(string musicId)
|
||||||
{
|
{
|
||||||
var blobs = Repo.GetAll();
|
var blobs = Repo.GetAll();
|
||||||
var blob = blobs.FirstOrDefault(x => x.MusicId == musicId);
|
var blob = blobs.FirstOrDefault(x => x.MusicId == musicId); if (blob == null)
|
||||||
return blob != null ? ByteConverterHelper.ReturnObject<RequestedModel>(blob.Content) : null;
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var model = ByteConverterHelper.ReturnObject<RequestedModel>(blob.Content);
|
||||||
|
model.Id = blob.Id;
|
||||||
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RequestedModel> CheckRequestAsync(string musicId)
|
public async Task<RequestedModel> CheckRequestAsync(string musicId)
|
||||||
{
|
{
|
||||||
var blobs = await Repo.GetAllAsync().ConfigureAwait(false);
|
var blobs = await Repo.GetAllAsync().ConfigureAwait(false);
|
||||||
var blob = blobs.FirstOrDefault(x => x.MusicId == musicId);
|
var blob = blobs.FirstOrDefault(x => x.MusicId == musicId);
|
||||||
return blob != null ? ByteConverterHelper.ReturnObject<RequestedModel>(blob.Content) : null;
|
|
||||||
|
if (blob == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var model = ByteConverterHelper.ReturnObject<RequestedModel>(blob.Content);
|
||||||
|
model.Id = blob.Id;
|
||||||
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteRequest(RequestedModel request)
|
public void DeleteRequest(RequestedModel request)
|
||||||
|
@ -130,6 +152,7 @@ namespace Ombi.Core
|
||||||
return new RequestedModel();
|
return new RequestedModel();
|
||||||
}
|
}
|
||||||
var model = ByteConverterHelper.ReturnObject<RequestedModel>(blob.Content);
|
var model = ByteConverterHelper.ReturnObject<RequestedModel>(blob.Content);
|
||||||
|
model.Id = blob.Id; // They should always be the same, but for somereason a user didn't have it in the db https://github.com/tidusjar/Ombi/issues/862#issuecomment-269743847
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,23 +164,44 @@ namespace Ombi.Core
|
||||||
return new RequestedModel();
|
return new RequestedModel();
|
||||||
}
|
}
|
||||||
var model = ByteConverterHelper.ReturnObject<RequestedModel>(blob.Content);
|
var model = ByteConverterHelper.ReturnObject<RequestedModel>(blob.Content);
|
||||||
|
model.Id = blob.Id;
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<RequestedModel> GetAll()
|
public IEnumerable<RequestedModel> GetAll()
|
||||||
{
|
{
|
||||||
var blobs = Repo.GetAll();
|
var blobs = Repo.GetAll().ToList();
|
||||||
return blobs.Select(b => Encoding.UTF8.GetString(b.Content))
|
var retVal = new List<RequestedModel>();
|
||||||
.Select(JsonConvert.DeserializeObject<RequestedModel>)
|
|
||||||
.ToList();
|
foreach (var b in blobs)
|
||||||
|
{
|
||||||
|
if (b == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var model = ByteConverterHelper.ReturnObject<RequestedModel>(b.Content);
|
||||||
|
model.Id = b.Id;
|
||||||
|
retVal.Add(model);
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<RequestedModel>> GetAllAsync()
|
public async Task<IEnumerable<RequestedModel>> GetAllAsync()
|
||||||
{
|
{
|
||||||
var blobs = await Repo.GetAllAsync().ConfigureAwait(false);
|
var blobs = await Repo.GetAllAsync().ConfigureAwait(false);
|
||||||
return blobs.Select(b => Encoding.UTF8.GetString(b.Content))
|
var retVal = new List<RequestedModel>();
|
||||||
.Select(JsonConvert.DeserializeObject<RequestedModel>)
|
|
||||||
.ToList();
|
foreach (var b in blobs)
|
||||||
|
{
|
||||||
|
if (b == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var model = ByteConverterHelper.ReturnObject<RequestedModel>(b.Content);
|
||||||
|
model.Id = b.Id;
|
||||||
|
retVal.Add(model);
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool BatchUpdate(IEnumerable<RequestedModel> model)
|
public bool BatchUpdate(IEnumerable<RequestedModel> model)
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace Ombi.Core
|
||||||
|
|
||||||
foreach (var u in users)
|
foreach (var u in users)
|
||||||
{
|
{
|
||||||
if (username == u.UserName)
|
if (username.Equals(u.UserName, StringComparison.CurrentCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
var passwordMatch = PasswordHasher.VerifyPassword(password, u.Salt, u.Hash);
|
var passwordMatch = PasswordHasher.VerifyPassword(password, u.Salt, u.Hash);
|
||||||
if (passwordMatch)
|
if (passwordMatch)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@using Nancy.Security
|
ab@using Nancy.Security
|
||||||
@using Nancy.Session
|
@using Nancy.Session
|
||||||
@using Nancy;
|
@using Nancy;
|
||||||
@using Ombi.Helpers
|
@using Ombi.Helpers
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-user"></i> @UI.Layout_Admin <span class="caret"></span></a>
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-user"></i> @UI.Layout_Admin <span class="caret"></span></a>
|
||||||
<ul class="dropdown-menu" role="menu">
|
<ul class="dropdown-menu" role="menu">
|
||||||
<li><a href="@url/admin/about>"><i class="fa fa-cog"></i> @UI.Layout_Settings</a></li>
|
<li><a href="@url/admin/about"><i class="fa fa-cog"></i> @UI.Layout_Settings</a></li>
|
||||||
<li><a href="@url/changepassword"><i class="fa fa-key"></i> @UI.Layout_ChangePassword</a></li>
|
<li><a href="@url/changepassword"><i class="fa fa-key"></i> @UI.Layout_ChangePassword</a></li>
|
||||||
|
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue