public async Task <IActionResult> Login(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                var user = userDatabaseRepository.login(model.username, model.password);
                if (user != null)
                {
                    var claims = new List <Claim>
                    {
                        new Claim(ClaimTypes.Role, "user"),
                        new Claim(ClaimTypes.NameIdentifier, user.userId.ToString()),
                        new Claim(ClaimTypes.Name, user.username)
                    };

                    if (user.isAdmin)
                    {
                        claims.Add(new Claim(ClaimTypes.Role, "admin"));
                    }

                    var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
                    await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity));

                    return(RedirectToAction("Index", "Profile"));
                }
                return(View("Index"));
            }
            return(View("Index"));
        }