Removed old code

pull/2356/head
Jamie Rees 6 years ago
parent a1c5124269
commit b56bc8c807

@ -114,50 +114,5 @@ namespace Ombi
x.TokenValidationParameters = tokenValidationParameters;
});
}
private static async Task ValidateUserAccessToken(IServiceProvider serviceProvider, HttpContext context, Func<Task> next, string key)
{
if (key.IsNullOrEmpty())
{
await context.Response.WriteAsync("Invalid User Access Token");
return;
}
var um = serviceProvider.GetService<OmbiUserManager>();
var user = await um.Users.FirstOrDefaultAsync(x => x.UserAccessToken == key);
if (user == null)
{
context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
await context.Response.WriteAsync("Invalid User Access Token");
}
else
{
var identity = new GenericIdentity(user.UserName);
var roles = await um.GetRolesAsync(user);
var principal = new GenericPrincipal(identity, roles.ToArray());
context.User = principal;
await next();
}
}
private static async Task ValidateApiKey(IServiceProvider serviceProvider, HttpContext context, Func<Task> next, string key)
{
var settingsProvider = serviceProvider.GetService<ISettingsService<OmbiSettings>>();
var ombiSettings = settingsProvider.GetSettings();
var valid = ombiSettings.ApiKey.Equals(key, StringComparison.CurrentCultureIgnoreCase);
if (!valid)
{
context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
await context.Response.WriteAsync("Invalid API Key");
}
else
{
var identity = new GenericIdentity("API");
var principal = new GenericPrincipal(identity, new[] { "Admin", "ApiUser" });
context.User = principal;
await next();
}
}
}
}
Loading…
Cancel
Save