-
-
Notifications
You must be signed in to change notification settings - Fork 567
/
Copy pathIndex.cshtml.cs
38 lines (34 loc) · 1005 Bytes
/
Index.cshtml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Copyright (c) 2019 Håkan Edling
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*
* https://github.com/piranhacms/piranha.core
*
*/
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace Piranha.Manager.Models
{
[Authorize(Policy = Permission.Admin)]
public class IndexModel : PageModel
{
private readonly IAuthorizationService _service;
public IndexModel(IAuthorizationService service)
{
_service = service;
}
public async Task<IActionResult> OnGet(string returnUrl = null)
{
var items = await Menu.Items.GetForUser(HttpContext.User, _service);
if (items.Count > 0)
{
return Redirect(items[0].Items[0].Route);
}
return RedirectToPage("Logout");
}
}
}