1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

fix gravatars not showing

fix web config not saving Uri
fix issue with token login
This commit is contained in:
RaidMax
2019-04-14 10:55:05 -05:00
parent 832bc941ec
commit 7c309ee460
21 changed files with 187 additions and 128 deletions

View File

@ -25,14 +25,14 @@ namespace WebfrontCore.Controllers
try
{
#if DEBUG == true
var client = Utilities.IW4MAdminClient();
bool loginSuccess = true;
#else
//#if DEBUG == true
// var client = Utilities.IW4MAdminClient();
// bool loginSuccess = true;
//#else
var client = Manager.GetPrivilegedClients()[clientId];
bool loginSuccess = Manager.TokenAuthenticator.AuthorizeToken(client.NetworkId, password) ||
(await Task.FromResult(SharedLibraryCore.Helpers.Hashing.Hash(password, client.PasswordSalt)))[0] == client.Password;
#endif
//#endif
if (loginSuccess)
{

View File

@ -53,6 +53,16 @@ namespace WebfrontCore.Controllers
};
var meta = await MetaService.GetRuntimeMeta(client.ClientId, 0, 1, DateTime.UtcNow);
var gravatar = await new MetaService().GetPersistentMeta("GravatarEmail", client);
if (gravatar != null)
{
clientDto.Meta.Add(new ProfileMeta()
{
Key = "GravatarEmail",
Type = ProfileMeta.MetaType.Other,
Value = gravatar.Value
});
}
var currentPenalty = activePenalties.FirstOrDefault();
@ -67,7 +77,7 @@ namespace WebfrontCore.Controllers
}
clientDto.Meta.AddRange(Authorized ? meta : meta.Where(m => !m.Sensitive));
ViewBag.Title = clientDto.Name.Substring(clientDto.Name.Length - 1).ToLower()[0] == 's' ?
clientDto.Name + "'" :
clientDto.Name + "'s";

View File

@ -1,17 +1,13 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SharedLibraryCore.Configuration;
using SharedLibraryCore.Interfaces;
using System.Linq;
using System.Threading.Tasks;
using WebfrontCore.ViewModels;
namespace WebfrontCore.Controllers
{
[Authorize]
public class ConfigurationController : BaseController
{
public IActionResult Edit()
@ -20,37 +16,42 @@ namespace WebfrontCore.Controllers
}
[HttpPost]
public async Task<IActionResult> Edit(ApplicationConfiguration newConfiguration)
public async Task<IActionResult> Edit(ApplicationConfiguration newConfiguration, bool addNewServer = false, bool shouldSave = false)
{
var currentConfiguration = Manager.GetApplicationSettings().Configuration();
var newConfigurationProperties = newConfiguration.GetType().GetProperties();
foreach (var property in currentConfiguration.GetType().GetProperties())
if (shouldSave)
{
var newProp = newConfigurationProperties.First(_prop => _prop.Name == property.Name);
var newPropValue = newProp.GetValue(newConfiguration);
var currentConfiguration = Manager.GetApplicationSettings().Configuration();
if (newPropValue != null && newProp.CanWrite)
var newConfigurationProperties = newConfiguration.GetType().GetProperties();
foreach (var property in currentConfiguration.GetType().GetProperties())
{
property.SetValue(currentConfiguration, newPropValue);
var newProp = newConfigurationProperties.First(_prop => _prop.Name == property.Name);
var newPropValue = newProp.GetValue(newConfiguration);
if (newPropValue != null && newProp.CanWrite)
{
property.SetValue(currentConfiguration, newPropValue);
}
}
await Manager.GetApplicationSettings().Save();
}
await Manager.GetApplicationSettings().Save();
if (addNewServer)
{
newConfiguration.Servers.Add(new ServerConfiguration());
}
return View("Index", newConfiguration);
}
public IActionResult GetNewListItem(string propertyName, int itemCount)
{
var config = Manager.GetApplicationSettings().Configuration();
var propertyInfo = config.GetType().GetProperties().First(_prop => _prop.Name == propertyName);
var configInfo = new ConfigurationInfo()
{
Configuration = config,
PropertyValue = (IList)propertyInfo.GetValue(config) ?? new List<string>(),
PropertyInfo = propertyInfo,
NewItemCount = itemCount
NewItemCount = itemCount,
PropertyName = propertyName
};
return PartialView("_ListItem", configInfo);