You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
47 lines
1.3 KiB
using System.Linq;
|
|
using Application.Domain.Entities;
|
|
using Infrastructure.Data;
|
|
using Infrastructure.Extensions;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace StudyCenter.Controllers
|
|
{
|
|
public class HomeController : Controller
|
|
{
|
|
private readonly IWebHostEnvironment _env;
|
|
private readonly IRepository<User> _userRepo;
|
|
|
|
public HomeController(IWebHostEnvironment env, IRepository<User> userRepo)
|
|
{
|
|
this._env = env;
|
|
this._userRepo = userRepo;
|
|
}
|
|
|
|
public IActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public IActionResult Privacy()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[Route("/Login")]
|
|
[AllowAnonymous]
|
|
public IActionResult Test()
|
|
{
|
|
var userName = "admin";
|
|
var userPermissions = this._userRepo.ReadOnlyTable().Where(o => o.UserName == userName)
|
|
.SelectMany(o => o.UserRoles)
|
|
.Select(o => o.Role)
|
|
.SelectMany(o => o.RolePermissions)
|
|
.Select(o => o.Permission.Number)
|
|
.ToList();
|
|
HttpContext.SignIn(userName, userPermissions, true);
|
|
return RedirectToAction("Index", "Home");
|
|
}
|
|
}
|
|
} |