示例#1
0
        public async Task <ActionResult> EditTimeZone(ProfileEditTimeZoneModel model)
        {
            if (!ModelState.IsValid)
            {
                if (model.TimeZones == null)
                {
                    model.TimeZones = GetTimeZones(string.IsNullOrEmpty(model.TimeZoneId));
                }
                return(View(model));
            }

            try
            {
                var svcTimeZoneData = new MUser_UpdateTimeZone()
                {
                    TimeZoneId = model.TimeZoneId
                };

                await UserMicroService.UpdateTimeZoneAsync(GetUserId(), svcTimeZoneData);

                UserLocale.RemoveFrom(HttpContext);

                AddFeedbackMessage(Feedback.FeedbackMessageTypes.Informational, "Timezone changed.");

                return(RedirectToAction("Index"));
            }
            catch (ServiceException ex)
            {
                AddModelErrors(ex);
                return(View());
            }
        }
示例#2
0
        public async Task <ActionResult> LogOff()
        {
            await SignInManager.SignOutAsync();

            UserLocale.RemoveFrom(HttpContext);

            return(RedirectToAction("Index", "Home"));
        }
示例#3
0
        public async Task <ActionResult> Index(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                var user = await UserMicroService.GetUserByNameAsync(model.Email);

                if (user == null)
                {
                    throw new ServiceException("Invalid user ID or password.");
                }

                var userId    = user.UserId;
                var confirmed = await UserMicroService.GetEmailConfirmedAsync(userId);

                if (!confirmed)
                {
                    await SendConfirmationEmailAsync(userId);

                    AddModelError("Your email address has not been confirmed.  A confirmation email has been sent.");
                    return(View());
                }

                var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.IsPersistent, lockoutOnFailure : true);

                if (result.IsLockedOut)
                {
                    AddModelError("This account has been locked out.  Please reset your password to recover.");
                    return(View());
                }
                else if (result.RequiresTwoFactor)
                {
                    // Used by two-factor authentication.
                    return(View());
                }
                else if (!result.Succeeded)
                {
                    AddModelError("Invalid user ID or password.");
                    return(View());
                }

                UserLocale.RemoveFrom(HttpContext);

                return(RedirectToLocal(returnUrl));
            }
            catch (ServiceException ex)
            {
                AddModelErrors(ex);
                return(View());
            }
        }