Ejemplo n.º 1
0
 public IActionResult Login(string ReturnNamedRoute=null, string ReturnController=null, int? ReturnID=null)
 {
     Login user = new Login();
     // Pull the controller and action out of the HTTP Context
     var currentaction = RoutingHttpContextExtensions.GetRouteData(this.HttpContext).Values["action"];
     string caller = (string)currentaction;
     // Set the Session variables for caller method
     HttpContext.Session.SetString("login_route",caller);
     if (ReturnNamedRoute != null && ReturnController != null)
     {
         // Set the View data information for Redirect
         HttpContext.Session.SetString("source_action", ReturnNamedRoute);
         HttpContext.Session.SetString("source_controller", ReturnController);
     }
     if (ReturnID != null)
     {
         // Set the View data information for the ID
         HttpContext.Session.SetInt32("source_id", (int)ReturnID);
     }
     User dbuser = fetchuser();
     if (dbuser != null)
     {
         // Navbar variables
         ViewBag.email = dbuser.Email;
     }
     // Variable for the caller in the method
     ViewBag.caller = caller;
     // Render the View with the User model
     return View(user);
 }
Ejemplo n.º 2
0
        /*  This is the user login check method
         *  Takes in a view name and a model for prepping the view returned */
        public dynamic user_check(string view = null, object model = null)
        {
            // Grab the user if it exists
            var user = fetchuser();

            // Check to make sure the user exists
            if (user == null)
            {
                // Pull the controller and action out of the HTTP Context
                var currentcontroller = RoutingHttpContextExtensions.GetRouteData(this.HttpContext).Values["controller"];
                var currentaction     = RoutingHttpContextExtensions.GetRouteData(this.HttpContext).Values["action"];
                var currentid         = RoutingHttpContextExtensions.GetRouteData(this.HttpContext).Values["id"];
                Console.WriteLine(currentid);
                // Redirect to the login page with the returnURL passed as parameters
                return(RedirectToAction("Login", "User", new { ReturnNamedRoute = currentaction, ReturnController = currentcontroller, ReturnID = currentid }));
            }
            else
            {
                // Return view with specific view name if passed in
                if (view == null)
                {
                    return(View(model));
                }
                else
                {
                    return(View(view, model));
                }
            }
        }
Ejemplo n.º 3
0
        /*  This is the user login check method
         *  Takes in a view name and a model for prepping the view returned */
        public dynamic user_login()
        {
            // Pull the controller and action out of the HTTP Context
            var currentcontroller = RoutingHttpContextExtensions.GetRouteData(this.HttpContext).Values["controller"];
            var currentaction     = RoutingHttpContextExtensions.GetRouteData(this.HttpContext).Values["action"];
            var currentid         = RoutingHttpContextExtensions.GetRouteData(this.HttpContext).Values["id"];

            // Redirect to the login page with the returnURL passed as parameters
            return(RedirectToAction("Login", "User", new { ReturnNamedRoute = currentaction, ReturnController = currentcontroller, ReturnID = currentid }));
        }