public ActionResult Index(User u)
        {
            Session["UserInfo"] = u_dsl.Login(u) as User;
            var temp = Session["UserInfo"] as User;

            if (temp != null)
            {
                return(RedirectToAction("Dashborad"));
            }
            return(View());
        }
Beispiel #2
0
        public IActionResult Login([FromBody] RequestedData <UserDTO> requestedData)
        {
            requestedData.Entity = userDSL.Login(requestedData.Entity.Username, requestedData.Entity.Password);
            if (requestedData.Entity != null)
            {
                var securityKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes("DentalClinicKey#12*"));
                var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
                var claims      = new[] { new Claim(JwtRegisteredClaimNames.NameId, requestedData.Entity.Id.ToString()) };
                var token       = new JwtSecurityToken(null, null, claims,
                                                       expires: DateTime.Now.AddDays(1),
                                                       signingCredentials: credentials);

                requestedData.Entity.Token = new JwtSecurityTokenHandler().WriteToken(token);
            }
            return(Ok(requestedData));
        }