コード例 #1
0
        public async Task <IActionResult> Login(LoginViewModel model, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;
            if (ModelState.IsValid)
            {
                var user = userDb.Get(new User {
                    UserName = model.UserName
                });
                if (user == null)
                {
                    ViewData["Message"] = "Kullanıcı adı yanlış! ";
                    return(View(model));
                }

                if (signInManager.GetClaimsPrincipal(model.UserName, model.Password,
                                                     user, out ClaimsPrincipal principal))
                {
                    await HttpContext.SignInAsync(principal);

                    return(RedirectToLocal(returnUrl));
                }
                else
                {
                    ViewData["Message"] = "Yanlış şifre! ";
                }
            }

            return(View(model));
        }
コード例 #2
0
 public async Task <List <User> > GetUsers()
 {
     return(await _dbUser.Get());
 }