using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using JtkMainServer.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace JtkMainServer.Pages.MyPage {
    public class IndexModel : PageModel {
        public string Message { get; set; }

        public IActionResult OnGet() {
            var userId = HttpContext.Session.GetString("LoggedInUserId");
            ViewData["LoggedInUserId"] = userId;
            if (string.IsNullOrWhiteSpace(userId)) {
                // 로그인 안 했을 시, 로그인 페이지로
                HttpContext.Session.SetString("RequestedPage", "MyPage/Index");
                return RedirectToPage("/Login");
            }
            return Page();
        }
        public IActionResult OnPost() => OnGet();
    }
}
