Exemplo n.º 1
0
        public async Task <CommonResult> ActiveAsync(ActiveUserModel criterias)
        {
            var user = await _userManager.FindByNameAsync(criterias.Email);

            if (!await _userManager.IsEmailConfirmedAsync(user))
            {
                var result = await _userManager.ConfirmEmailAsync(user, criterias.ActiveKey);

                if (result.Succeeded)
                {
                    return(CommonResult.Success());
                }

                var errors = result.Errors.Select(x => new CommonError()
                {
                    Message = x.Description,
                    Code    = x.Code
                });

                return(CommonResult.Failed(errors));
            }

            return(CommonResult.Failed(new CommonError()
            {
                Message = "The user is already confirmed"
            }));
        }
Exemplo n.º 2
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var activeUser = await _userManager.GetUserAsync((System.Security.Claims.ClaimsPrincipal) User);

            var model = new ActiveUserModel
            {
                Name    = activeUser.Name,
                Surname = activeUser.Surname,
                Image   = activeUser.ImageUrl
            };

            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult SignIn(ActiveUserModel activeUser, string ReturnUrl)
        {
            if (!string.IsNullOrEmpty(activeUser.Login) && !string.IsNullOrEmpty(activeUser.Password))
            {
                if (OhSnapDAL.Managers.AccountManager.IsUserValid(activeUser.Login, activeUser.Password))
                {
                    FormsAuthentication.SetAuthCookie(activeUser.Login, false);

                    return(RedirectToAction("Index", "Home"));
                }

                ViewBag.Warning = "Incorrect Login or Password.";
                return(View("SignIn"));
            }

            return(View(activeUser));
        }
Exemplo n.º 4
0
 public async Task <CommonResult> ActiveAsync([Service] IUserResolver userResolver, ActiveUserModel criterias)
 {
     return(await userResolver.ActiveAsync(criterias));
 }