public static string GeneratePayLinkURL(string PayLinkID)
        {
            SystemSettingsRepository sysRepo = new SystemSettingsRepository();
            var sys = sysRepo.GetSystemSettings();

            string _PayLink = sys.CurrentDomain + "/Home/PayNow/" + PayLinkID;

            return(_PayLink);
        }
        public static string GenerateDashboardURL(string DashboardURL)
        {
            SystemSettingsRepository sysRepo = new SystemSettingsRepository();
            var sys = sysRepo.GetSystemSettings();

            string _PayLink = sys.CurrentDomain + "/Member/" + DashboardURL;

            return(_PayLink);
        }
Beispiel #3
0
        public ActionResult GetCurrentDomain()
        {
            SystemSettingsRepository sysRepo = new SystemSettingsRepository();
            var sys = sysRepo.GetSystemSettings();

            return(new JsonResult {
                Data = sys.CurrentDomain
            });
        }
        public ActionResult ForgottenPassword(ForgottenPasswordModel model)
        {
            bool   status = true;
            string exMsg  = "";

            if (ModelState.IsValid)
            {
                SystemSettingsRepository sysRepo = new SystemSettingsRepository();
                var sys = sysRepo.GetSystemSettings();
                using (DBEntities db = new DBEntities())
                {
                    Users user = db.Users.FirstOrDefault(u => u.EmailAddress == model.Email);
                    if (user != null)
                    {
                        //Now Send an Email to User for Username and Password!
                        if (sys.EmailsEnabled)
                        {
                            try
                            {
                                //Random rndm = new Random();
                                //var RandomNum = rndm.Next(10001, int.MaxValue);
                                Guid   guid = Guid.NewGuid();
                                string EncryptedRandomNum = guid.ToString();
                                SecurityUtils.CheckforInvalidFileNameChar(ref EncryptedRandomNum); //it will remove any unsupported characters
                                user.PasswordResetCode = EncryptedRandomNum;
                                user.ResetCodeExpiry   = DateTime.Now.AddHours(2);
                                db.SaveChanges();

                                status = SendEmail(user, EncryptedRandomNum);
                            }
                            catch (Exception ex)
                            {
                                ViewBag.status = "Failed to send an Email. Please contact your Site Administrator" + ex.Message;
                                exMsg          = ex.Message;
                            }

                            if (status)
                            {
                                //Add To Log
                                SecurityUtils.AddAuditLog("Requested for Forgotten Password", "User \"" + user.FullName + "\" requested for Forgotten Password , Email Sent to: \"" + user.EmailAddress + "\"", this);
                                ViewBag.status = "Your Login Details has been sent to above email address. <a style='color:black' href='/Account/Logon'> Log On </a>";
                            }
                            else
                            {
                                ViewBag.status = "Failed to send an Email. Please contact your Site Administrator." + exMsg + " - " + EmailsRepository.EmailErrorMsg;
                            }
                        }
                    }
                    else
                    {
                        ViewBag.status = "Your provided email address is not valid. Please contact site Administrator.";
                    }
                }
            }

            return(View());
        }
Beispiel #5
0
        public ActionResult Index()
        {
            SystemSettingsRepository sysRepo = new SystemSettingsRepository();
            var sysSetting = sysRepo.GetSystemSettings();

            sysSetting.PaymentModes = DropDownLists.GetPaymentModes(sysSetting.GoCardless_Mode);
            ViewBag.Msg             = "";
            ViewBag.MsgCss          = "";
            return(View(sysSetting));
        }
        public bool SendEmail(Users user, string EncryptedRandomNum)
        {
            SystemSettingsRepository sysRepo = new SystemSettingsRepository();
            var sys = sysRepo.GetSystemSettings();

            string ResetPasswordLink = sys.CurrentDomain + "/Account/ResetPassword?id=" + EncryptedRandomNum;
            string Body = "Dear " + user.FullName + "," +
                          "<br/>" +
                          "<br/> Please <a href='" + ResetPasswordLink + "'>Click here</a> to Reset your Password at MANvFAT Football";

            EmailsRepository emailRepo = new EmailsRepository();

            return(emailRepo.SendEmail(SecurityUtils.SiteAdminEmail, user.EmailAddress, "Reset Password at MANvFAT Football", Body));
        }
Beispiel #7
0
        public ActionResult ForgottenPassword(ForgottenPasswordModel model)
        {
            bool   status = true;
            string exMsg  = "";

            if (ModelState.IsValid)
            {
                using (DBEntities db = new DBEntities())
                {
                    var playerDashboard = db.PlayerDashboard.FirstOrDefault(u => u.DashboardURL == model.DashboardURLId);

                    PlayersRepository playerRepo = new PlayersRepository();
                    var player = playerRepo.ReadOne_ByEmailAddress(model.Email, true);

                    if (playerDashboard != null && player != null)
                    {
                        //Now Send an Email to User for Username and Password!
                        //  if (sys.EmailsEnabled)
                        {
                            try
                            {
                                SystemSettingsRepository sysRepo = new SystemSettingsRepository();
                                var sys = sysRepo.GetSystemSettings();

                                //Random rndm = new Random();
                                //var RandomNum = rndm.Next(10001, int.MaxValue);
                                Guid   guid = Guid.NewGuid();
                                string EncryptedRandomNum = guid.ToString();
                                SecurityUtils.CheckforInvalidFileNameChar(ref EncryptedRandomNum); //it will remove any unsupported characters
                                playerDashboard.PasswordResetCode = EncryptedRandomNum;
                                playerDashboard.ResetCodeExpiry   = DateTime.Now.AddHours(24);
                                db.SaveChanges();

                                status = SendEmail(player, EncryptedRandomNum, sys.CurrentDomain);
                            }
                            catch (Exception ex)
                            {
                                model.Reason    = "Failed to send an Email. Please contact your Site Administrator" + ex.Message;
                                model.AlertType = "danger";
                                exMsg           = ex.Message;
                            }

                            if (status)
                            {
                                //Add To Log
                                SecurityUtils.AddAuditLog("Requested for Forgotten Password", "User \"" + player.FullName + "\" requested for Forgotten Password , Email Sent to: \"" + player.EmailAddress + "\"", this);
                                model.Reason    = "Your Login Details has been sent to above email address. <a style='color:black' href='/Member/Login/" + model.DashboardURLId + "'> Log In </a>";
                                model.AlertType = "success";
                            }
                            else
                            {
                                model.Reason    = "Failed to send an Email. Please contact your Site Administrator." + exMsg + " - " + EmailsRepository.EmailErrorMsg;
                                model.AlertType = "danger";
                            }
                        }
                    }
                    else
                    {
                        model.Reason    = "Your provided email address is not valid. Please contact us at [email protected]";
                        model.AlertType = "danger";
                    }
                }
            }

            ViewBag.ModelIsLogin = true;

            return(View(model));
        }
        // GET: Base
        protected override void OnActionExecuted(ActionExecutedContext context)
        {
            if (context.Exception != null)
            {
                ErrorHandling.HandleException(context.Exception);
            }

            var result = context.Result as ViewResultBase;

            if (result == null)
            {
                // The controller action didn't return a view result
                // => no need to continue any further
                return;
            }

            bool    _IsAdmin = false, _IsLeagueViewer = false, _IsCoach = false, _DownForMaintenance = false;
            bool    _IsTechUser              = false; //[email protected] and [email protected] are the Tech users, and only allowed to edit System Settings.
            decimal _TotalLostByAllLeagues   = 0.00M;
            string  _DownForMaintenance_Time = "";

            string[] TechUserEmails = { "*****@*****.**", "*****@*****.**", "*****@*****.**" };

            try
            {
                if (User.Identity.IsAuthenticated)
                {
                    var LoggedInUser = SecurityUtils.GetUserDetails();
                    if (LoggedInUser != null)
                    {
                        _IsAdmin        = (LoggedInUser.RoleID == (long)Permissions.Administrator);
                        _IsLeagueViewer = (LoggedInUser.RoleID == (long)Permissions.LeagueViewer);
                        _IsCoach        = (LoggedInUser.RoleID == (long)Permissions.Coaches);
                        _IsTechUser     = (TechUserEmails.Any(m => m.ToLower().Equals(LoggedInUser.EmailAddress.ToLower())));
                    }

                    SystemSettingsRepository sysRepo = new SystemSettingsRepository();
                    var sys = sysRepo.GetSystemSettings();
                    _DownForMaintenance      = sys.DownForMaintenance;
                    _DownForMaintenance_Time = sys.DownForMaintenance_Timer;
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.HandleException(ex);
            }

            ViewBag.IsAdmin                 = _IsAdmin;
            ViewBag.IsLeagueViewer          = _IsLeagueViewer;
            ViewBag.IsCoach                 = _IsCoach;
            ViewBag.IsTechUser              = _IsTechUser;
            ViewBag.TotalLostByAllLeagues   = _TotalLostByAllLeagues.ToString("N2");
            ViewBag.DownForMaintenance      = _DownForMaintenance;
            ViewBag.DownForMaintenance_Time = _DownForMaintenance_Time;

            //var model = result.Model as BaseVm;
            //if (model == null)
            //{
            //    // there's no model or the model was not of the expected type
            //    // => no need to continue any further
            //    return;
            //}

            //var userName = UserPropertiesGetter.GetUserName(context.HttpContext);
            //var userPropertiesGetter = new UserPropertiesGetter();
            ////Get the Roles and Permissions for this user
            //var dataRolesPermissions = userPropertiesGetter.GetDataRolesPermissions(context.HttpContext, userName);

            ////Get the users permissions for each controller action in the application
            //var permissionsHelper = new PermissionsHelper();
            //permissionsHelper.GetAppPermissions(dataRolesPermissions);

            //// Put the user data into the viewmodel
            //model.UserDataRolesPermissions = dataRolesPermissions;
        }
        public ActionResult LogOn(LogOnModel model, string returnUrl, FormCollection formcollection)
        {
            RemoveUserfromSession();

            if (returnUrl != null)
            {
                if (returnUrl.Contains("%2f"))
                {
                    returnUrl = Server.UrlDecode(returnUrl);
                }
            }
            bool locked = false, IsMobileNumVerified = false;

            if (ModelState.IsValid)
            {
                if (ValidateUser(model.UserName, model.Password, ref locked, ref IsMobileNumVerified))
                {
                    //Disable Mobile Verification On TEST and Development from System Settings
                    SystemSettingsRepository systemSettingsRepo = new SystemSettingsRepository();
                    var Enable_MobileVerification = systemSettingsRepo.GetSystemSettings().Enable_MobileVerification;

                    if (Enable_MobileVerification == false)
                    {
                        //If Mobile Verification is Disabled, then Don't redirect to Mobile Verification Page and force the system to assume that Mobile is Verified
                        IsMobileNumVerified = true;
                    }


                    if (!locked && IsMobileNumVerified)
                    {
                        FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);

                        if ((long)Session["RoleID"] == (long)Permissions.LeagueViewer)
                        {
                            return(RedirectToAction("LocalAuthLeagues", "Leagues"));
                        }
                        else
                        {
                            if (returnUrl != null)
                            {
                                return(Redirect(returnUrl));
                            }
                            else
                            {
                                return(RedirectToAction("Index", "Admin"));
                            }
                        }
                    }
                    else if (IsMobileNumVerified == false)
                    {
                        return(RedirectToAction("MobileVerification", "Account"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "You cannot log on the System, because your status is Locked. Please contact site Administrator.");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }