Esempio n. 1
0
 public IActionResult LMS_Reporting(LMSModel model, string report)
 {
     // Check user athorisation to start
     if (HttpContext.Request.Cookies.ContainsKey("MoodleSession"))
     {
         // User is logged in, continue with request for report
         ViewData["Report"] = report;
         return(View("LMS_Reporting", model));
     }
     else
     {
         // Not logged in, return to login page
         ViewData["Error"] = "You must be logged in via LMS to view this page. Please log in below.";
         return(RedirectToAction("Login"));
     }
 }
Esempio n. 2
0
 public IActionResult Index(LMSModel model)
 {
     // Double check authorisation
     if (HttpContext.Request.Cookies.ContainsKey("MoodleSession"))
     {
         // User is already authorised, display page
         ViewData["Title"]   = "LMS Reporting";
         ViewData["Message"] = "Access to the LMS reports below.";
         return(View(model));
     }
     else
     {
         // Not logged in via LMS, send on to login
         ViewData["Error"] = "You must be logged in via LMS to view this page. Please log in below.";
         return(RedirectToAction("Login"));
     }
 }
Esempio n. 3
0
        public async Task <IActionResult> Login(LMSModel model, string username, string password)
        {
            if (HttpContext.Request.Method == HttpMethod.Get.Method)
            {
                // Get, check if already logged in
                if (HttpContext.Request.Cookies.ContainsKey("MoodleSession"))
                {
                    // Logged in, redirect to management page
                    ViewData["Title"]   = "LMS Reporting";
                    ViewData["Message"] = "Access to the LMS reports below.";
                    return(RedirectToAction("LMS_Reporting"));
                }
                else
                {
                    // Not logged in, display login form
                    ViewData["Title"]   = "Login via LMS";
                    ViewData["Message"] = "Use your LMS login credentials to authenticate before accessing the LMS management tools.";
                    return(View(model));
                }
            }
            else
            {
                // Post, attempt login
                await LMS_Login(username, password);                 // *** Validation on inputs needs to be added - use equivalent to LMS rules

                if (HttpContext.Request.Cookies.ContainsKey("MoodleSession"))
                {
                    // Login succeded
                    ViewData["Title"]   = "LMS Reporting";
                    ViewData["Message"] = "Access to the LMS reports below.";
                    return(RedirectToAction("LMS_Reporting"));
                }
                else
                {
                    // Login failed
                    ViewData["Title"] = "Login via LMS";
                    ViewData["Error"] = "Login with LMS failed. Check your details and retry.";
                    return(View(model));
                }
            }
        }