Exemple #1
0
        public string MyAuthenticate(string cid, string socialId, string wc = "tc")
        {
            // string cid = refid.Split('-')[0].Trim();
            //   string whichconsole = "tc";

            MyAuthenticateResponse authResponse = this.ServiceClient.Send <MyAuthenticateResponse>(new Authenticate
            {
                provider = CredentialsAuthProvider.Name,
                UserName = "******",
                Password = "******",
                Meta     = new Dictionary <string, string> {
                    { "wc", wc }, { "cid", cid }, { "socialId", socialId }
                },
                // UseTokenCookie = true
            });

            //if (authResponse != null)
            //{
            //    CookieOptions options = new CookieOptions();
            //    Response.Cookies.Append("botToken", authResponse.BearerToken, options);
            //    Response.Cookies.Append("rToken", authResponse.RefreshToken, options);
            //    this.ServiceClient.BearerToken = authResponse.BearerToken;
            //    this.ServiceClient.RefreshToken = authResponse.RefreshToken;

            //}
            return(authResponse.ToJson());
        }
        public IActionResult ProfileSetup(int i)
        {
            var req = this.HttpContext.Request.Form;
            var res = this.ServiceClient.Post <CreateAccountResponse>(new CreateAccountRequest {
                op = "updatetenant", Colvalues = req.ToDictionary(dict => dict.Key, dict => (object)dict.Value), Token = ViewBag.token
            });

            if (res.id >= 0)
            {
                MyAuthenticateResponse authResponse = this.ServiceClient.Get <MyAuthenticateResponse>(new Authenticate
                {
                    provider = CredentialsAuthProvider.Name,
                    UserName = res.email,
                    Password = (req["Password"] + res.email).ToMD5Hash(),
                    Meta     = new Dictionary <string, string> {
                        { "wc", "tc" }, { "cid", "expressbase" }
                    },
                    //UseTokenCookie = true
                });
                if (authResponse != null)
                {
                    CookieOptions options = new CookieOptions();
                    Response.Cookies.Append("bToken", authResponse.BearerToken, options);
                    Response.Cookies.Append("rToken", authResponse.RefreshToken, options);
                    this.ServiceClient.BearerToken  = authResponse.BearerToken;
                    this.ServiceClient.RefreshToken = authResponse.RefreshToken;
                }
                return(RedirectToAction("TenantDashboard", "Tenant"));
            }

            return(View());
        }
        public IActionResult VerificationStatus()
        {
            var email      = HttpContext.Request.Query["email"];
            var token      = HttpContext.Request.Query["signup_tok"];
            var authClient = this.ServiceClient;
            MyAuthenticateResponse authResponse = authClient.Send <MyAuthenticateResponse>(new Authenticate
            {
                provider = CredentialsAuthProvider.Name,
                UserName = email,
                Password = "******",
                Meta     = new Dictionary <string, string> {
                    { "signup_tok", token }, { "wc", "tc" }
                },
                // UseTokenCookie = true
            });

            if (authResponse != null)
            {
                ViewBag.SuccessMessage = "Successfully Verified";
            }
            else
            {
                ViewBag.SuccessMessage = "Verification failed";
            }
            return(View());
        }
        public IActionResult AfterSignInSocial(string provider, string providerToken,
                                               string email, string socialId, int lg)
        {
            try
            {
                var authClient = this.ServiceClient;
                MyAuthenticateResponse authResponse = authClient.Send <MyAuthenticateResponse>(new Authenticate
                {
                    provider = CredentialsAuthProvider.Name,
                    UserName = "******",
                    Password = "******",
                    Meta     = new Dictionary <string, string> {
                        { "wc", "tc" }, { "cid", "expressbase" }, { "socialId", socialId }
                    },
                    // UseTokenCookie = true
                });

                if (authResponse.User != null)
                {
                    CookieOptions options = new CookieOptions();
                    Response.Cookies.Append(RoutingConstants.BEARER_TOKEN, authResponse.BearerToken, options);
                    Response.Cookies.Append(RoutingConstants.REFRESH_TOKEN, authResponse.RefreshToken, options);
                    return(RedirectToAction("TenantDashboard", "Tenant"));
                    //if (lg <= 1)
                    //{
                    //    return RedirectToAction("ProfileSetup", "Tenant");
                    //}
                    //{
                    //}
                }
                else
                {
                    return(RedirectToAction("Error", "Ext"));
                }
            }
            catch (WebServiceException wse)
            {
                ViewBag.errormsg = wse.Message;
                return(RedirectToAction("Error", "Ext"));
            }
        }
Exemple #5
0
        public List <object> AuthAndGetformlist(string cid, string socialId, string wc = "tc")
        {
            MyAuthenticateResponse authResponse = this.ServiceClient.Send <MyAuthenticateResponse>(new Authenticate
            {
                provider = CredentialsAuthProvider.Name,
                UserName = "******",
                Password = "******",
                Meta     = new Dictionary <string, string> {
                    { "wc", wc }, { "cid", cid }, { "socialId", socialId }
                },
            });

            if (authResponse != null)
            {
                this.ServiceClient.BearerToken  = authResponse.BearerToken;
                this.ServiceClient.RefreshToken = authResponse.RefreshToken;
                var tokenS = (new JwtSecurityTokenHandler()).ReadToken(authResponse.BearerToken) as JwtSecurityToken;


                ViewBag.cid   = tokenS.Claims.First(claim => claim.Type == "cid").Value;
                ViewBag.wc    = tokenS.Claims.First(claim => claim.Type == "wc").Value;
                ViewBag.email = tokenS.Claims.First(claim => claim.Type == "email").Value;

                User user = this.Redis.Get <User>(string.Format("{0}-{1}-{2}", ViewBag.cid, ViewBag.email, ViewBag.wc));
                var  Ids  = String.Join(",", user.EbObjectIds);
                GetBotForm4UserResponse formlist = this.ServiceClient.Get <GetBotForm4UserResponse>(new GetBotForm4UserRequest {
                    BotFormIds = "{" + Ids + "}"
                });
                List <object> returnlist = new List <object>();
                returnlist.Add(authResponse);
                returnlist.Add(formlist.BotForms);
                return(returnlist);
            }
            else
            {
                return(null);
            }
        }
Exemple #6
0
        public ReportRenderResponse Post(ReportRenderMultipleMQRequest request)
        {
            string Displayname = "";

            this.Ms1 = new MemoryStream();
            this.EbConnectionFactory = new EbConnectionFactory(request.SolnId, this.Redis);

            JsonServiceClient      authClient   = this.ServiceStackClient;
            MyAuthenticateResponse authResponse = authClient.Get <MyAuthenticateResponse>(new Authenticate
            {
                provider = CredentialsAuthProvider.Name,
                UserName = GetUserObject(request.ReadingUserAuthId)?.Email,
                Password = "******",
                Meta     = new Dictionary <string, string> {
                    { RoutingConstants.WC, RoutingConstants.UC },
                    { TokenConstants.CID, request.SolnId },
                    { "sso", "true" },
                    { TokenConstants.IP, "" },
                    { RoutingConstants.USER_AGENT, "" }
                },
            });

            this.FileClient.BearerToken  = authResponse?.BearerToken;
            this.FileClient.RefreshToken = authResponse?.RefreshToken;

            List <EbObjectWrapper> resultlist = EbObjectsHelper.GetParticularVersion(this.EbConnectionFactory.ObjectsDB, request.RefId);
            EbReport ReportObject             = EbSerializers.Json_Deserialize <EbReport>(resultlist[0].Json);

            ReportObject.ObjectsDB     = this.EbConnectionFactory.ObjectsDB;
            ReportObject.Redis         = this.Redis;
            ReportObject.FileClient    = this.FileClient;
            ReportObject.Solution      = GetSolutionObject(request.SolnId);
            ReportObject.ReadingUser   = GetUserObject(request.ReadingUserAuthId);
            ReportObject.RenderingUser = GetUserObject(request.RenderingUserAuthId);

            ReportObject.CultureInfo = CultureHelper.GetSerializedCultureInfo(ReportObject.ReadingUser?.Preference.Locale ?? "en-US").GetCultureInfo();
            ReportObject.GetWatermarkImages();

            try
            {
                byte[] encodedDataAsBytes = System.Convert.FromBase64String(request.Params);
                string returnValue        = System.Text.ASCIIEncoding.ASCII.GetString(encodedDataAsBytes);

                List <Param> _paramlist = (returnValue == null) ? null : JsonConvert.DeserializeObject <List <Param> >(returnValue);
                if (_paramlist != null)
                {
                    for (int i = 0; i < _paramlist.Count; i++)
                    {
                        string[] values = _paramlist[i].Value.Split(',');

                        for (int j = 0; j < values.Length; j++)
                        {
                            List <Param> _newParamlist = new List <Param>
                            {
                                new Param {
                                    Name = "id", Value = values[j], Type = "7"
                                }
                            };

                            this.Report = ReportObject;

                            if (Report != null)
                            {
                                InitializePdfObjects();
                                Report.Doc.NewPage();
                                Report.GetData4Pdf(_newParamlist, EbConnectionFactory);

                                if (Report.DataSet != null)
                                {
                                    Report.Draw();
                                }
                                else
                                {
                                    throw new Exception();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception-reportService " + e.Message + e.StackTrace);
                Report.HandleExceptionPdf();
            }

            Report.Doc.Close();

            if (Report.DataSourceRefId != string.Empty && Report.DataSet != null)
            {
                Report.DataSet.Tables.Clear();
                Report.DataSet = null;
            }

            Displayname = Regex.Replace(((Displayname == "") ? Report.DisplayName : Displayname), @"\s+", "");

            Ms1.Position = 0;

            string uid = request.RefId + request.UserId + request.SubscriptionId;

            byte[] compressedData = Compress(Ms1.ToArray());

            this.Redis.Set("PdfReport" + uid, compressedData, DateTime.Now.AddMinutes(15));

            this.ServerEventClient.BearerToken     = authResponse?.BearerToken;
            this.ServerEventClient.RefreshToken    = authResponse?.RefreshToken;
            this.ServerEventClient.RefreshTokenUri = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_GET_ACCESS_TOKEN_URL);

            Console.WriteLine("Calling NotifySubscriptionRequest to subsc.id :" + request.SubscriptionId);
            this.ServerEventClient.Post <NotifyResponse>(new NotifySubscriptionRequest
            {
                Msg              = "/DV/GetPdf?refid=" + uid + "&filename=" + Displayname + ".pdf",
                Selector         = StaticFileConstants.PDFDOWNLOADSUCCESS,
                ToSubscriptionId = request.SubscriptionId
            });

            return(new ReportRenderResponse());
        }
        public async Task <IActionResult> TenantSignin(int i)
        {
            var host = this.HttpContext.Request.Host;

            string[] hostParts    = host.Host.Split('.');
            string   whichconsole = null;
            var      req          = this.HttpContext.Request.Form;

            string _controller = null;
            string _action     = null;

            //CHECK WHETHER SOLUTION ID IS VALID

            bool bOK2AttemptLogin = true;

            if (host.Host.EndsWith(RoutingConstants.EXPRESSBASEDOTCOM))
            {
                this.DecideConsole(req["console"], hostParts[0], (hostParts.Length == 3), out whichconsole);
            }

            else if (host.Host.EndsWith(RoutingConstants.EBTESTINFO))
            {
                this.DecideConsole(req["console"], hostParts[0], (hostParts.Length == 3), out whichconsole);
            }

            else if (host.Host.EndsWith(RoutingConstants.LOCALHOST))
            {
                this.DecideConsole(req["console"], hostParts[0], (hostParts.Length == 2), out whichconsole);
            }

            else
            {
                bOK2AttemptLogin = false;
                _controller      = "Ext";
                _action          = "Error";
            }

            if (bOK2AttemptLogin)
            {
                string    token = req["g-recaptcha-response"];
                Recaptcha data  = await RecaptchaResponse("6LcQuxgUAAAAAD5dzks7FEI01sU61-vjtI6LMdU4", token);

                if (!data.Success)
                {
                    if (data.ErrorCodes.Count <= 0)
                    {
                        return(RedirectToAction("Error", "Ext"));
                    }
                    var error = data.ErrorCodes[0].ToLower();
                    switch (error)
                    {
                    case ("missing-input-secret"):
                        ViewBag.CaptchaMessage = "The secret parameter is missing.";
                        break;

                    case ("invalid-input-secret"):
                        ViewBag.CaptchaMessage = "The secret parameter is invalid or malformed.";
                        break;

                    case ("missing-input-response"):
                        ViewBag.CaptchaMessage = "The captcha input is missing.";
                        break;

                    case ("invalid-input-response"):
                        ViewBag.CaptchaMessage = "The captcha input is invalid or malformed.";
                        break;

                    default:
                        ViewBag.CaptchaMessage = "Error occured. Please try again";
                        break;
                    }
                    return(RedirectToAction("Error", "Ext"));
                }
                else
                {
                    MyAuthenticateResponse authResponse = null;
                    try
                    {
                        string tenantid   = ViewBag.cid;
                        var    authClient = this.ServiceClient;
                        authResponse = authClient.Get <MyAuthenticateResponse>(new Authenticate
                        {
                            provider = CredentialsAuthProvider.Name,
                            UserName = req["uname"],
                            Password = (req["pass"] + req["uname"]).ToMD5Hash(),
                            Meta     = new Dictionary <string, string> {
                                { "wc", whichconsole }, { "cid", tenantid }
                            },
                            //UseTokenCookie = true
                        });
                    }
                    catch (WebServiceException wse)
                    {
                        TempData["ErrorMessage"] = wse.Message;
                        return(errorredirect(whichconsole));
                    }
                    catch (Exception wse)
                    {
                        TempData["ErrorMessage"] = wse.Message;
                        return(errorredirect(whichconsole));
                    }
                    if (authResponse != null && authResponse.ResponseStatus != null && authResponse.ResponseStatus.ErrorCode == "EbUnauthorized")
                    {
                        TempData["ErrorMessage"] = "EbUnauthorized";
                        return(errorredirect(whichconsole));
                    }
                    else //AUTH SUCCESS
                    {
                        CookieOptions options = new CookieOptions();

                        Response.Cookies.Append(RoutingConstants.BEARER_TOKEN, authResponse.BearerToken, options);
                        Response.Cookies.Append(RoutingConstants.REFRESH_TOKEN, authResponse.RefreshToken, options);

                        if (req.ContainsKey("remember"))
                        {
                            Response.Cookies.Append("UserName", req["uname"], options);
                        }

                        this.RouteToDashboard(authResponse.User.HasSystemRole(), whichconsole, out _controller, out _action);
                    }
                }
            }

            return(RedirectToAction(_action, _controller));
        }
        public async Task <IActionResult> TenantSignin(int i)
        {
            // string url = this.HttpContext.Request.Headers["HOST"];
            var host = this.HttpContext.Request.Host;

            string[] subdomain    = host.Host.Split('.');
            string   whichconsole = null;
            var      req          = this.HttpContext.Request.Form;



            if (host.Host.EndsWith("expressbase.com") || host.Host.EndsWith("expressbase.org"))
            {
                if (subdomain.Length == 3) // USER CONSOLE
                {
                    if (!string.IsNullOrEmpty(req["console"]))
                    {
                        ViewBag.cid  = subdomain[0];
                        whichconsole = "dc";
                    }
                    else
                    {
                        ViewBag.cid  = subdomain[0];
                        whichconsole = "uc";
                    }
                }
                else // TENANT CONSOLE
                {
                    ViewBag.cid  = "expressbase";
                    whichconsole = "tc";
                }
            }
            else if (host.Host.EndsWith("localhost"))
            {
                if (subdomain.Length == 2) // USER CONSOLE
                {
                    if (!string.IsNullOrEmpty(req["console"]))
                    {
                        ViewBag.cid  = subdomain[0];
                        whichconsole = "dc";
                    }
                    else
                    {
                        ViewBag.cid  = subdomain[0];
                        whichconsole = "uc";
                    }
                }
                else // TENANT CONSOLE
                {
                    ViewBag.cid  = "expressbase";
                    whichconsole = "tc";
                }
            }
            else if (host.Host.EndsWith("nip.io") || host.Host.EndsWith("xip.io"))
            {
                if (subdomain.Length == 7) // USER CONSOLE
                {
                    if (!string.IsNullOrEmpty(req["console"]))
                    {
                        ViewBag.cid  = subdomain[0];
                        whichconsole = "dc";
                    }
                    else
                    {
                        ViewBag.cid  = subdomain[0];
                        whichconsole = "uc";
                    }
                }
                else // TENANT CONSOLE
                {
                    ViewBag.cid  = "expressbase";
                    whichconsole = "tc";
                }
            }
            else
            {
                if (subdomain.Length == 5) // USER CONSOLE
                {
                    if (!string.IsNullOrEmpty(req["console"]))
                    {
                        ViewBag.cid  = subdomain[0];
                        whichconsole = "dc";
                    }
                    else
                    {
                        ViewBag.cid  = subdomain[0];
                        whichconsole = "uc";
                    }
                }
                else
                {
                    ViewBag.cid  = "expressbase";
                    whichconsole = "tc";
                }
            }

            MyAuthenticateResponse authResponse = null;

            string    token = req["g-recaptcha-response"];
            Recaptcha data  = await RecaptchaResponse("6LcQuxgUAAAAAD5dzks7FEI01sU61-vjtI6LMdU4", token);

            if (!data.Success)
            {
                if (data.ErrorCodes.Count <= 0)
                {
                    return(RedirectToAction("Error", "Ext"));
                }
                var error = data.ErrorCodes[0].ToLower();
                switch (error)
                {
                case ("missing-input-secret"):
                    ViewBag.CaptchaMessage = "The secret parameter is missing.";
                    break;

                case ("invalid-input-secret"):
                    ViewBag.CaptchaMessage = "The secret parameter is invalid or malformed.";
                    break;

                case ("missing-input-response"):
                    ViewBag.CaptchaMessage = "The captcha input is missing.";
                    break;

                case ("invalid-input-response"):
                    ViewBag.CaptchaMessage = "The captcha input is invalid or malformed.";
                    break;

                default:
                    ViewBag.CaptchaMessage = "Error occured. Please try again";
                    break;
                }
                return(RedirectToAction("Error", "Ext"));
            }
            else
            {
                try
                {
                    Console.WriteLine("..............................In try for authenticate");
                    string tenantid   = ViewBag.cid;
                    var    authClient = this.ServiceClient;
                    authResponse = authClient.Get <MyAuthenticateResponse>(new Authenticate
                    {
                        provider = CredentialsAuthProvider.Name,
                        UserName = req["uname"],
                        Password = (req["pass"] + req["uname"]).ToMD5Hash(),
                        Meta     = new Dictionary <string, string> {
                            { "wc", whichconsole }, { "cid", tenantid }
                        },
                        //UseTokenCookie = true
                    });
                }
                catch (WebServiceException wse)
                {
                    TempData["ErrorMessage"] = wse.Message;
                    return(errorredirect(whichconsole));
                }
                catch (Exception wse)
                {
                    TempData["ErrorMessage"] = wse.Message;
                    return(errorredirect(whichconsole));
                }
                if (authResponse != null && authResponse.ResponseStatus != null &&
                    authResponse.ResponseStatus.ErrorCode == "EbUnauthorized")
                {
                    TempData["ErrorMessage"] = "EbUnauthorized";
                    return(errorredirect(whichconsole));
                }
                else
                {
                    Console.WriteLine("...........................Authentication Success");
                    CookieOptions options = new CookieOptions();

                    Response.Cookies.Append("bToken", authResponse.BearerToken, options);
                    Response.Cookies.Append("rToken", authResponse.RefreshToken, options);

                    if (req.ContainsKey("remember"))
                    {
                        Response.Cookies.Append("UserName", req["uname"], options);
                    }

                    if (host.Host.EndsWith("expressbase.com") || host.Host.EndsWith("expressbase.org"))
                    {
                        Console.WriteLine("..........................Authentication Success expressbase.com/ expressbase.org");
                        if (ViewBag.cid == "expressbase")
                        {
                            Console.WriteLine("....................Authentication Success expressbase.com/ expressbase.org tenandid=expressbase");
                            if (subdomain.Length == 3 && authResponse.User.HasEbSystemRole() && whichconsole == "dc")
                            {
                                Console.WriteLine(".................Authentication Success expressbase.com/ expressbase.org tenandid=expressbase DevConsole");
                                return(RedirectToAction("DevConsole", "Dev"));
                            }
                            else if (subdomain.Length == 3 && authResponse.User.Roles.Contains("Eb_User") && whichconsole == "uc") // USER CONSOLE
                            {
                                Console.WriteLine("..................Authentication Success expressbase.com/ expressbase.org tenandid=expressbase UserConsole");
                                return(RedirectToAction("UserDashboard", "TenantUser"));
                            }
                            else if (authResponse.User.loginattempts <= 2) // TENANT CONSOLE
                            {
                                Console.WriteLine("........................Authentication Success expressbase.com/ expressbase.org tenandid=expressbase ProfileSetup");
                                return(RedirectToAction("ProfileSetup", "Tenant"));
                            }
                            else
                            {
                                Console.WriteLine("..................Authentication Success expressbase.com/ expressbase.org tenandid=expressbase TenantConsole");
                                return(RedirectToAction("TenantDashboard", "Tenant"));
                            }
                        }
                        else
                        {
                            Console.WriteLine(".....................Authentication Success expressbase.com/ expressbase.org tenandid=eb_roby_dev");

                            if (subdomain.Length == 3 && authResponse.User.HasSystemRole() && whichconsole == "dc")
                            {
                                Console.WriteLine(".................Authentication Success expressbase.com/ expressbase.org tenandid=eb_roby_dev DevConsole");
                                return(RedirectToAction("DevConsole", "Dev"));
                            }
                            else if (subdomain.Length == 3 && whichconsole == "uc") // USER CONSOLE
                            {
                                Console.WriteLine(".....................Authentication Success expressbase.com/ expressbase.org tenandid=eb_roby_dev UserConsole");
                                return(RedirectToAction("UserDashboard", "TenantUser"));
                            }
                            else if (authResponse.User.loginattempts <= 2) // TENANT CONSOLE
                            {
                                Console.WriteLine("...................Authentication Success expressbase.com/ expressbase.org tenandid=eb_roby_dev ProfileSetup");
                                return(RedirectToAction("ProfileSetup", "Tenant"));
                            }
                            else
                            {
                                Console.WriteLine("...................Authentication Success expressbase.com/ expressbase.org tenandid=eb_roby_dev TenantConsole");
                                return(RedirectToAction("TenantDashboard", "Tenant"));
                            }
                        }
                    }

                    else if (host.Host.EndsWith("localhost"))
                    {
                        Console.WriteLine(".....................Authentication Success localhost");
                        if (ViewBag.cid == "expressbase")
                        {
                            Console.WriteLine(".....................Authentication Success localhost tenandid=expressbase");
                            if (subdomain.Length == 2 && authResponse.User.HasEbSystemRole() && whichconsole == "dc")
                            {
                                Console.WriteLine(".................Authentication Success localhost tenandid=expressbase DevConsole");
                                return(RedirectToAction("DevConsole", "Dev"));
                            }
                            else if (subdomain.Length == 2 && authResponse.User.Roles.Contains("Eb_User") && whichconsole == "uc") // USER CONSOLE
                            {
                                Console.WriteLine(".................Authentication Success localhost tenandid=expressbase UserConsole");
                                return(RedirectToAction("UserDashboard", "TenantUser"));
                            }
                            else if (authResponse.User.loginattempts <= 2) // TENANT CONSOLE
                            {
                                Console.WriteLine(".................Authentication Success localhost tenandid=expressbase ProfileSetUp");
                                return(RedirectToAction("ProfileSetup", "Tenant"));
                            }
                            else
                            {
                                Console.WriteLine(".................Authentication Success localhost tenandid=expressbase TenantConsole");
                                return(RedirectToAction("TenantDashboard", "Tenant"));
                            }
                        }
                        else
                        {
                            Console.WriteLine(".....................Authentication Success localhost tenandid=eb_roby_dev");
                            if (subdomain.Length == 2 && authResponse.User.HasSystemRole() && whichconsole == "dc")
                            {
                                Console.WriteLine(".................Authentication Success localhost tenandid=eb_roby_dev DevConsole");
                                return(RedirectToAction("DevConsole", "Dev"));
                            }
                            else if (subdomain.Length == 2 && whichconsole == "uc") // USER CONSOLE
                            {
                                Console.WriteLine(".................Authentication Success localhost tenandid=eb_roby_dev UserConsole");
                                return(RedirectToAction("UserDashboard", "TenantUser"));
                            }
                            else if (authResponse.User.loginattempts == 2) // TENANT CONSOLE
                            {
                                Console.WriteLine(".................Authentication Success localhost tenandid=eb_roby_dev ProfileSetUp");
                                return(RedirectToAction("ProfileSetup", "Tenant"));
                            }
                            else
                            {
                                Console.WriteLine(".................Authentication Success localhost tenandid=eb_roby_dev TenantConsole");
                                return(RedirectToAction("TenantDashboard", "Tenant"));
                            }
                        }
                    }
                    else if (host.Host.EndsWith("nip.io") || host.Host.EndsWith("xip.io"))
                    {
                        Console.WriteLine(".....................Authentication Success nip.io/xip.io");
                        if (ViewBag.cid == "expressbase")
                        {
                            Console.WriteLine(".....................Authentication Success nip.io/xip.io tenantid=expressbase");
                            if (subdomain.Length == 7 && authResponse.User.HasEbSystemRole() && whichconsole == "dc")
                            {
                                Console.WriteLine(".....................Authentication Success nip.io/xip.io tenantid=expressbase DevConsole");
                                return(RedirectToAction("DevConsole", "Dev"));
                            }
                            else if (subdomain.Length == 7 && authResponse.User.Roles.Contains("Eb_User") && whichconsole == "uc") // USER CONSOLE
                            {
                                Console.WriteLine(".....................Authentication Success nip.io/xip.io tenantid=expressbase UserConsole");
                                return(RedirectToAction("UserDashboard", "TenantUser"));
                            }
                            else if (authResponse.User.loginattempts == 2) // TENANT CONSOLE
                            {
                                Console.WriteLine(".....................Authentication Success nip.io/xip.io tenantid=expressbase ProfileSetup");
                                return(RedirectToAction("ProfileSetup", "Tenant"));
                            }
                            else
                            {
                                Console.WriteLine(".....................Authentication Success nip.io/xip.io tenantid=expressbase TenantConsole");
                                return(RedirectToAction("TenantDashboard", "Tenant"));
                            }
                        }
                        else
                        {
                            Console.WriteLine(".....................Authentication Success nip.io/xip.io tenantid=eb_roby_dev");
                            if (subdomain.Length == 7 && authResponse.User.HasSystemRole() && whichconsole == "dc")
                            {
                                Console.WriteLine(".....................Authentication Success nip.io/xip.io tenantid=eb_roby_dev DevConsole");
                                return(RedirectToAction("DevConsole", "Dev"));
                            }


                            else if (subdomain.Length == 7 && whichconsole == "uc") // USER CONSOLE
                            {
                                Console.WriteLine(".....................Authentication Success nip.io/xip.io tenantid=eb_roby_dev UserConsole");
                                return(RedirectToAction("UserDashboard", "TenantUser"));
                            }
                            else if (authResponse.User.loginattempts == 2) // TENANT CONSOLE
                            {
                                Console.WriteLine(".....................Authentication Success nip.io/xip.io tenantid=eb_roby_dev ProfileSetup");
                                return(RedirectToAction("ProfileSetup", "Tenant"));
                            }
                            else
                            {
                                Console.WriteLine(".....................Authentication Success nip.io/xip.io tenantid=eb_roby_dev TenantConsole");
                                return(RedirectToAction("TenantDashboard", "Tenant"));
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine(".....................Authentication Success Normal IP");
                        if (ViewBag.cid == "expressbase")
                        {
                            Console.WriteLine(".....................Authentication Success Normal IP tenandid=expressbase");
                            if (subdomain.Length == 5 && authResponse.User.HasEbSystemRole() && whichconsole == "dc")
                            {
                                Console.WriteLine(".....................Authentication Success Normal IP tenandid=expressbase DevConsole");
                                return(RedirectToAction("DevConsole", "Dev"));
                            }
                            else if (subdomain.Length == 5 && authResponse.User.Roles.Contains("Eb_User") && whichconsole == "uc") // USER CONSOLE
                            {
                                Console.WriteLine(".....................Authentication Success Normal IP tenandid=expressbase UserConsole");
                                return(RedirectToAction("UserDashboard", "TenantUser"));
                            }
                            else if (authResponse.User.loginattempts == 2) // TENANT CONSOLE
                            {
                                Console.WriteLine(".....................Authentication Success Normal IP tenandid=expressbase ProfileSetup");
                                return(RedirectToAction("ProfileSetup", "Tenant"));
                            }
                            else
                            {
                                Console.WriteLine(".....................Authentication Success Normal IP tenandid=expressbase TenantConsole");
                                return(RedirectToAction("TenantDashboard", "Tenant"));
                            }
                        }
                        else
                        {
                            Console.WriteLine(".....................Authentication Success Normal IP tenandid=eb_roby_dev");
                            if (subdomain.Length == 5 && authResponse.User.HasSystemRole() && whichconsole == "dc")
                            {
                                Console.WriteLine(".....................Authentication Success Normal IP tenandid=eb_roby_dev DevConsole");
                                return(RedirectToAction("DevConsole", "Dev"));
                            }


                            else if (subdomain.Length == 5 && whichconsole == "uc") // USER CONSOLE
                            {
                                Console.WriteLine(".....................Authentication Success Normal IP tenandid=eb_roby_dev UserConsole");
                                return(RedirectToAction("UserDashboard", "TenantUser"));
                            }
                            else if (authResponse.User.loginattempts == 2) // TENANT CONSOLE
                            {
                                Console.WriteLine(".....................Authentication Success Normal IP tenandid=eb_roby_dev ProfileSetup");
                                return(RedirectToAction("ProfileSetup", "Tenant"));
                            }
                            else
                            {
                                Console.WriteLine(".....................Authentication Success Normal IP tenandid=eb_roby_dev TenantConsole");
                                return(RedirectToAction("TenantDashboard", "Tenant"));
                            }
                        }
                    }


                    //if (subdomain.Length == 2)
                    //{
                    //    if(authResponse.User.loginattempts <= 2)
                    //        return RedirectToAction("ProfileSetup", "Tenant");
                    //    else
                    //        return RedirectToAction("TenantDashboard", "Tenant");
                    //}
                    //else if (subdomain.Length == 3 && authResponse.User.RoleCollection.HasSystemRole())
                    //    return RedirectToAction("DevConsole", "Dev");
                    //else
                    //    return RedirectToAction("UserDashboard", "TenantUser");
                }
            }
        }