public virtual ActionResult LoginStatus()
        {
            var model = new LoginStatusViewModel
            {
                IsUserAuthenticated = false
            };

            return(View(MVC.Account.Views.LoginStatus, model));
        }
        public LoginStatusViewModel GetCurrentUser(string email)
        {
            var manager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new ApplicationDbContext()));
            //throw new DatabaseNotFoundException();

            var model = manager.FindByEmail(email);

            if (model == null)
            {
                throw new UserNotFoundException();
            }

            var viewModel = new LoginStatusViewModel();

            viewModel.DisplayName = model.DisplayName;
            return(viewModel);
        }
Пример #3
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var users = await this.userProfileRepo.GetAllAsync();

            var vm = new LoginStatusViewModel
            {
                UserProfiles = users.Select(x => new UserProfileViewModel {
                    Id = x.Id, DisplayName = x.DisplayName
                })
            };

            var id = this.HttpContext.Session.GetInt32(SessionKeys.CurrentUserId);

            if (id.HasValue)
            {
                vm.IsLoggedIn  = true;
                vm.CurrentUser = vm.UserProfiles.FirstOrDefault(x => x.Id == id.Value);
            }

            return(View(vm));
        }
Пример #4
0
 public ActionResult LoginStatus()
 {
     var principal = authenticationService.GetCurrentPrincipal();
       var viewModel = new LoginStatusViewModel() {
     UserIsLoggedIn = principal.Identity.IsAuthenticated
       };
       if (viewModel.UserIsLoggedIn) {
     viewModel.Username = principal.Identity.Name;
       }
       return PartialView(viewModel);
 }
Пример #5
0
        public HttpResponseMessage Login(LoginViewModel loginViewModel)
        {
            var result = new LoginStatusViewModel();

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Пример #6
0
        // POST api/values
        public object Post([FromBody] LoginCredentialViewModel loginCredential)
        {
            //string hashedPassword = Security.HashSHA1(loginCredential.password + userGuid.ToString());
            LoginStatusViewModel loginStatus = new LoginStatusViewModel();

            loginStatus.userId          = "";
            loginStatus.userName        = "";
            loginStatus.userAccountType = "";


            MsMobileUserProfile matchUser;

            try
            {
                using (PatuhEntities db = new PatuhEntities())
                {
                    //MsMobileUserProfile listProfile =  db.MsMobileUserProfiles.Where(x => x.UserID == loginCredential.userId).FirstOrDefault();

                    matchUser = db.MsMobileUserProfiles.Where(x => x.UserID == loginCredential.userId).FirstOrDefault();//db.MsMobileUserProfiles.Where(x => x.UserID == loginCredential.userId).DefaultIfEmpty(new MsMobileUserProfile()).FirstOrDefault();

                    if (matchUser != null)
                    {
                        string hashedPassword = Security.HashSHA1(loginCredential.password + matchUser.UserGuid);

                        if (matchUser.Pwd == hashedPassword)
                        {
                            // The password is correct
                            loginStatus.userId          = matchUser.UserID ?? "";
                            loginStatus.userName        = matchUser.FullName ?? "";
                            loginStatus.userAccountType = matchUser.UserAccountType ?? "";

                            MsMobileUserProfileViewModel msMobileUserProfileViewModel = new MsMobileUserProfileViewModel();
                            msMobileUserProfileViewModel.UserID          = matchUser.UserID;
                            msMobileUserProfileViewModel.Pwd             = matchUser.Pwd;
                            msMobileUserProfileViewModel.UserGuid        = matchUser.UserGuid;
                            msMobileUserProfileViewModel.UserAccountType = matchUser.UserAccountType;
                            msMobileUserProfileViewModel.FullName        = matchUser.FullName;
                            msMobileUserProfileViewModel.DOB             = (matchUser.DOB != null ? matchUser.DOB.Value.ToString("dd-MM-yyyy") : "");
                            msMobileUserProfileViewModel.Location        = matchUser.Location;
                            msMobileUserProfileViewModel.PhoneNo         = matchUser.PhoneNo;
                            msMobileUserProfileViewModel.Email           = matchUser.Email;


                            IList <TrPoint> listPoint = db.TrPoints.Where(x => x.UserID == matchUser.UserID).ToList();

                            if (listPoint != null)
                            {
                                msMobileUserProfileViewModel.PointReward = (listPoint.Select(x => x.PointValue.Value).Sum());
                            }
                            loginStatus.userProfile = msMobileUserProfileViewModel;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                return(e);
            }

            return(loginStatus);
        }