This repository has been archived on 2023-04-02. You can view files and clone it, but cannot push or open issues or pull requests.
trainav/trainav.web/Pages/Index.cshtml.cs

20 lines
534 B
C#
Raw Normal View History

using System.Linq;
2020-06-11 20:29:16 +02:00
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.RazorPages;
2022-04-29 14:59:24 +02:00
using trainav.web.database;
using trainav.web.database.Tables;
2020-06-11 20:29:16 +02:00
2022-05-03 00:20:02 +02:00
namespace trainav.web.Pages;
2020-06-11 20:29:16 +02:00
2022-05-03 00:20:02 +02:00
public class IndexModel : PageModel {
public User AuthorizedUser;
2020-06-11 20:29:16 +02:00
2022-05-03 00:20:02 +02:00
public void OnGet() {
if (HttpContext.Session.GetString("authorized") != "true")
return;
var uid = int.Parse(HttpContext.Session.GetString("uid"));
using var db = new Database.DbConn();
AuthorizedUser = db.Users.FirstOrDefault(p => p.UserId == uid);
2020-06-11 20:29:16 +02:00
}
}