Exemple #1
0
        public InlogViewModel accountToViewmodel(InlogModel inlog)
        {
            InlogViewModel account = new InlogViewModel()
            {
                Email    = inlog.Email,
                Password = inlog.Password
            };

            return(account);
        }
 private bool KontrolleraGast(InlogModel gastInfo)
 {
     if (gastInfo.GastMejl == "Pedro" && gastInfo.Losenord == "Pass")
     {
         //gissar att vi behöver länk till inlogservice
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public async Task <IActionResult> Index(InlogModel gastInfo, string returnUrl = null)
        {
            bool gastGiltig = KontrolleraGast(gastInfo);

            if (gastGiltig == true)
            {
                var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme);
                identity.AddClaim(new Claim(ClaimTypes.Name, gastInfo.GastMejl));
                await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity));

                if (returnUrl != null)
                {
                    return(Redirect(returnUrl));
                }
                else
                {
                    return(RedirectToAction("Index", "Gast"));
                }
            }
            ViewBag.FelMeddelande = "Login failed. Please try again";
            return(View());
        }
 public bool LogintoTravelplan(InlogModel login)
 {
     return(context.Login(login.Email, login.Password));
 }