Exemplo n.º 1
0
        public IActionResult Post([FromBody] UserLogginDTO dto)
        {
            var user  = _getLoggedUser.Execute(dto);
            var userl = new LoggedUser();

            userl.Id        = user.Id;
            userl.FirstName = user.FirstName;
            userl.LastName  = user.LastName;
            userl.Role      = user.RoleName;
            userl.Username  = user.Username;


            var stringObjekat = JsonConvert.SerializeObject(userl);

            var encrypted = _enc.EncryptString(stringObjekat);

            return(Ok(new { token = encrypted }));
        }
		public UserResponseDTO Execute(UserLogginDTO request)
		{
			var user = AiContext.Users.AsQueryable()
				.Include(x => x.Role)
				.Where(p => p.Username == request.Username)
				.Where(p => p.Password == request.Password)
				.FirstOrDefault();
			if (user != null)
				return new UserResponseDTO
				{
					Id = user.Id,
					FirstName = user.FirstName,
					LastName = user.LastName,
					Username = user.Username,
					RoleId = user.RoleId,
					RoleName = user.Role.Name,
					Password = user.Password
				};
			return null;
		}