public ActionResult LogOff()
        {
            UserLogonViewModel logonUser = Session["logon_user"] as UserLogonViewModel;

            //Check whether the UserLogonViewModel received from the Session is null
            if (logonUser != null)
            {
                //Since it is not null, destroy it from the session by assigning the session with null
                Session["logon_user"] = null;
            }

            return(RedirectToAction("Login", "Accounts"));
        }
 public UserLogOnModel Map(UserLogonViewModel logOnViewModel)
 {
     return(new UserLogOnModel()
     {
         Email = logOnViewModel.Email,
         Password = logOnViewModel.Password,
         PhoneNumber = logOnViewModel.PhoneNumber,
         LoginLocation = logOnViewModel.LoginLocation,
         RequestURL = logOnViewModel.RequestURL,
         TenantID = logOnViewModel.TanentId,
         CreatedByEntity = logOnViewModel.CreatedByEntity,
         DeviceId = logOnViewModel.DeviceId
     });
 }
        public ActionResult Login(Accounts loginAccount, string returnUrl)
        {
            TempData["ReturnUrl"] = returnUrl;
            bool     modelState_FirstPass = ModelState.IsValid;
            Accounts userInfo             = null;

            if (modelState_FirstPass)
            {
                string userName_ToCheck = loginAccount.user_name.ToLower().Replace(" ", string.Empty);
                userInfo = accountsGateway.findByUserName(userName_ToCheck);

                if (userInfo == null)
                {
                    ModelState.AddModelError(Constants.ACCOUNTS_MODEL_KEYS[0], Constants.ENTERED_USERNAME_INVALID);
                }
                else if (!userInfo.password.Equals(loginAccount.password))
                {
                    ModelState.AddModelError(Constants.ACCOUNTS_MODEL_KEYS[1], Constants.ENTERED_PASSWORD_INVALID);
                }
            }

            if (ModelState.IsValid)
            {
                //Save the information of the successful logged on user to the UesrLogonViewModel
                //and then save it as a session
                Session["logon_user"] = new UserLogonViewModel()
                {
                    full_name = userInfo.full_name,
                    user_name = userInfo.user_name,
                    user_role = userInfo.user_role
                };
                return(RedirectToLocal(returnUrl));
            }

            return(View(loginAccount));
        }
 public string ValidateUserLogOn(UserLogonViewModel userLogOnViewModel)
 {
     return("");
 }