Sfoglia il codice sorgente

auto login natcash

student 1 giorno fa
parent
commit
7954466743

+ 2 - 0
website/Controllers/AccountController.cs

@@ -180,6 +180,7 @@ namespace LotteryWebApp.Controllers
                         };
                         UserStatus userStatus = api.GetUserStatusApi(configuration, userStatusRequest);
                         HttpContext.Session.SetComplexData("userStatus", userStatus);
+                        HttpContext.Session.SetString("ShowChooseAppAfterLogin", "1");
                     }
                     return Json(new
                     {
@@ -290,6 +291,7 @@ namespace LotteryWebApp.Controllers
             {
                 return Redirect(GetParameter(Constants.SUB_DOMAIN) + "/Account/Login");
             }
+            HttpContext.Session.Remove("ShowChooseAppAfterLogin");
             return View();
         }
 

+ 64 - 3
website/Controllers/HomeController.cs

@@ -46,6 +46,27 @@ namespace LotteryWebApp.Controllers
             return View();
         }
 
+        [HttpGet("/token={token}")]
+        public Task<IActionResult> LegacyTokenAsync(
+            string token,
+            string uuid,
+            string mcuid,
+            string phonenumber,
+            string termType
+        )
+        {
+            log.Info(
+                "App entry route: legacy /token=[REDACTED]; "
+                    + "tokenPresent="
+                    + !string.IsNullOrEmpty(token)
+                    + "; uuidPresent="
+                    + !string.IsNullOrEmpty(uuid)
+                    + "; phonenumberPresent="
+                    + !string.IsNullOrEmpty(phonenumber)
+            );
+            return IndexAsync(termType, uuid, mcuid, phonenumber, token);
+        }
+
         public JsonResult SetCulture(string lang)
         {
             try
@@ -78,9 +99,42 @@ namespace LotteryWebApp.Controllers
             //String url = CreatePrivateURL(configuration, param, "seconds", "0", "0", GetParameter("rsaPolicy"));
 
 
+            string requestPath = HttpContext.Request.Path.Value ?? "";
+            if (requestPath.StartsWith("/token=", StringComparison.OrdinalIgnoreCase))
+            {
+                requestPath = "/token=[REDACTED]";
+            }
+            log.Info(
+                "Home entry request: path="
+                    + requestPath
+                    + "; queryKeys="
+                    + string.Join(",", HttpContext.Request.Query.Keys)
+                    + "; tokenPresent="
+                    + !string.IsNullOrEmpty(token)
+                    + "; uuidPresent="
+                    + !string.IsNullOrEmpty(uuid)
+                    + "; mcuidPresent="
+                    + !string.IsNullOrEmpty(mcuid)
+                    + "; phonenumberPresent="
+                    + !string.IsNullOrEmpty(phonenumber)
+            );
+
+
             HomeIndex_ViewModel model = new HomeIndex_ViewModel();
             try
             {
+                if (
+                    CheckAuthToken()
+                    && HttpContext.Session.GetString("ShowChooseAppAfterLogin") == "1"
+                )
+                {
+                    HttpContext.Session.Remove("ShowChooseAppAfterLogin");
+                    log.Info("Manual login fallback: redirecting /Home to /Account/ChooseApp");
+                    return Redirect(
+                        GetParameter(Constants.SUB_DOMAIN) + "/Account/ChooseApp"
+                    );
+                }
+
                 HttpContext.Session.SetComplexData("navigator", Constants.HOME_NAVIGATOR);
 
                 CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
@@ -91,11 +145,16 @@ namespace LotteryWebApp.Controllers
                 // check auto login ?uuid=681471d23b83f0a463e2dd5671ea0fc5
                 // ?uuid=681471d23b83f0a463e2dd5671ea0fc5&mcuid=6c6948a89908d83aec8c05be256970a1&mcapp=mocha
 
-                if (!CheckAuthToken())
+                if (
+                    !CheckAuthToken()
+                    || token != null
+                    || uuid != null
+                    || phonenumber != null
+                )
                 {
                     //String uri = HttpContext.Request.QueryString.ToUriComponent().ToString();
                     log.Info("UUID: " + uuid);
-                    log.Info("token: " + token);
+                    log.Info("tokenPresent: " + !string.IsNullOrEmpty(token));
                     //token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ1c2VySW5mb3IiLCJleHAiOjE3MTAzODE0NTksInV1aWQiOiI1MGEwYjNlNzk5ZjllZDU3YTE1ZjZjNjljODVmYTM3NSJ9.EgR-P_KzsHJ1XCdgeu25Gy_-qAHOfM9uv9RTZSvr0AA";
 
                     if (token != null)
@@ -221,7 +280,9 @@ namespace LotteryWebApp.Controllers
                             {
                                 HttpContext.Session.Remove("regInfos");
                                 HttpContext.Session.SetComplexData("msisdn", msisdnDetect);
-
+                                return Redirect(
+                                    GetParameter(Constants.SUB_DOMAIN) + "/Account/ChooseApp"
+                                );
                                 // return to login
                                 return Redirect(
                                     GetParameter(Constants.SUB_DOMAIN) + "/Account/Login?step=2"