optimizations and fixes
This commit is contained in:
@ -312,8 +312,8 @@ namespace Oqtane.Controllers
|
||||
fileparts = Directory.GetFiles(folder, "*" + token + "*");
|
||||
foreach (string filepart in fileparts)
|
||||
{
|
||||
DateTime createddate = System.IO.File.GetCreationTime(filepart);
|
||||
if (createddate < DateTime.Now.AddHours(-2))
|
||||
DateTime createddate = System.IO.File.GetCreationTime(filepart).ToUniversalTime();
|
||||
if (createddate < DateTime.UtcNow.AddHours(-2))
|
||||
{
|
||||
System.IO.File.Delete(filepart);
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ namespace Oqtane.Controllers
|
||||
{
|
||||
version = new ApplicationVersion();
|
||||
version.Version = Constants.Version;
|
||||
version.CreatedOn = DateTime.Now;
|
||||
version.CreatedOn = DateTime.UtcNow;
|
||||
db.ApplicationVersion.Add(version);
|
||||
db.SaveChanges();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ using Oqtane.Shared;
|
||||
using System.Linq;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Security;
|
||||
using System.Net;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
@ -70,6 +71,31 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
// GET api/<controller>/path/x?path=y
|
||||
[HttpGet("path/{siteid}")]
|
||||
public Page Get(string path, int siteid)
|
||||
{
|
||||
Page page = _pages.GetPage(WebUtility.UrlDecode(path), siteid);
|
||||
if (page != null)
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(User, "View", page.Permissions))
|
||||
{
|
||||
return page;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access Page {Page}", page);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HttpContext.Response.StatusCode = 404;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
|
@ -111,7 +111,7 @@ namespace Oqtane.Controllers
|
||||
string url = HttpContext.Request.Scheme + "://" + _tenants.GetAlias().Name + "/login?name=" + User.Username + "&token=" + WebUtility.UrlEncode(token);
|
||||
notification.Body = "Dear " + User.DisplayName + ",\n\nIn Order To Complete The Registration Of Your User Account Please Click The Link Displayed Below:\n\n" + url + "\n\nThank You!";
|
||||
notification.ParentId = null;
|
||||
notification.CreatedOn = DateTime.Now;
|
||||
notification.CreatedOn = DateTime.UtcNow;
|
||||
notification.IsDelivered = false;
|
||||
notification.DeliveredOn = null;
|
||||
_notifications.AddNotification(notification);
|
||||
@ -240,10 +240,9 @@ namespace Oqtane.Controllers
|
||||
if (identityuser.EmailConfirmed)
|
||||
{
|
||||
user.IsAuthenticated = true;
|
||||
user.LastLoginOn = DateTime.Now;
|
||||
user.LastLoginOn = DateTime.UtcNow;
|
||||
user.LastIPAddress = HttpContext.Connection.RemoteIpAddress.ToString();
|
||||
_users.UpdateUser(user);
|
||||
_syncManager.AddSyncEvent("User", user.UserId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "User Login Successful {Username}", User.Username);
|
||||
if (SetCookie)
|
||||
{
|
||||
@ -272,7 +271,6 @@ namespace Oqtane.Controllers
|
||||
public async Task Logout([FromBody] User User)
|
||||
{
|
||||
await HttpContext.SignOutAsync(IdentityConstants.ApplicationScheme);
|
||||
_syncManager.AddSyncEvent("User", User.UserId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "User Logout {Username}", User.Username);
|
||||
}
|
||||
|
||||
@ -324,7 +322,7 @@ namespace Oqtane.Controllers
|
||||
string url = HttpContext.Request.Scheme + "://" + _tenants.GetAlias().Name + "/reset?name=" + User.Username + "&token=" + WebUtility.UrlEncode(token);
|
||||
notification.Body = "Dear " + User.DisplayName + ",\n\nPlease Click The Link Displayed Below To Reset Your Password:\n\n" + url + "\n\nThank You!";
|
||||
notification.ParentId = null;
|
||||
notification.CreatedOn = DateTime.Now;
|
||||
notification.CreatedOn = DateTime.UtcNow;
|
||||
notification.IsDelivered = false;
|
||||
notification.DeliveredOn = null;
|
||||
_notifications.AddNotification(notification);
|
||||
|
@ -12,11 +12,13 @@ namespace Oqtane.Controllers
|
||||
public class UserRoleController : Controller
|
||||
{
|
||||
private readonly IUserRoleRepository _userRoles;
|
||||
private readonly ISyncManager _syncManager;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public UserRoleController(IUserRoleRepository userRoles, ILogManager logger)
|
||||
public UserRoleController(IUserRoleRepository userRoles, ISyncManager syncManager, ILogManager logger)
|
||||
{
|
||||
_userRoles = userRoles;
|
||||
_syncManager = syncManager;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@ -44,6 +46,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
UserRole = _userRoles.AddUserRole(UserRole);
|
||||
_syncManager.AddSyncEvent("User", UserRole.UserId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "User Role Added {UserRole}", UserRole);
|
||||
}
|
||||
return UserRole;
|
||||
@ -57,6 +60,7 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
UserRole = _userRoles.UpdateUserRole(UserRole);
|
||||
_syncManager.AddSyncEvent("User", UserRole.UserId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "User Role Updated {UserRole}", UserRole);
|
||||
}
|
||||
return UserRole;
|
||||
@ -67,8 +71,10 @@ namespace Oqtane.Controllers
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
UserRole userRole = _userRoles.GetUserRole(id);
|
||||
_userRoles.DeleteUserRole(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "User Role Deleted {UserRoleId}", id);
|
||||
_syncManager.AddSyncEvent("User", userRole.UserId);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "User Role Deleted {UserRole}", userRole);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user