public IActionResult Login(LoginModels user) { //тестовое использование ComputerService // var manufacturers = _advansedComputerService.GetComputerManufacturers(); var manufacturers = _computerService.GetComputerManufacturers(); if (user == null) { return(BadRequest("Invalid data")); } if (user.UserName == "jon" && user.Password == "123") { var secretKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("superSecretKey@345")); var signinCredentials = new SigningCredentials(secretKey, SecurityAlgorithms.HmacSha256); var tokenOptions = new JwtSecurityToken( issuer: "http://localhost:5000", audience: "http://localhost:5000", claims: new List <Claim>(), expires: DateTime.Now.AddMinutes(5), signingCredentials: signinCredentials ); var tokenString = new JwtSecurityTokenHandler().WriteToken(tokenOptions); return(Ok(new{ Token = tokenString })); } else { return(Unauthorized()); } }
public List <User> GetAllUsers() { //тестовое использование ComputerService // var manufacturers = _advansedComputerService.GetComputerManufacturers(); var manufacturers = _computerService.GetComputerManufacturers(); return(_userService.GetAll()); }
public ActionResult <List <ComputerManufacturerDto> > GetManufacturers() { return(_computerService.GetComputerManufacturers()); }
public ActionResult <List <ComputerManufacturerDto> > GetManufacturers() { // return _advansedComputerService.GetComputerManufacturers(); return(_computerService.GetComputerManufacturers()); }
public List <User> GetAllUsers() { var manufacturers = _computerService.GetComputerManufacturers(); return(_userService.GetAll()); }