public async Task <RepoResponse <Seller> > Login(SellerLoginDto seller) { var sellers = await _context.Sellers .AsNoTracking() .Where(s => s.Email == seller.Email) .ToListAsync(); foreach (var s in sellers) { if (s.Password == seller.Password) { var token = GenerateSellerToken(s); return(new RepoResponse <Seller>() { Content = s, IsSucces = true, Message = $"Bearer {token}" }); } } return(new RepoResponse <Seller>() { Content = null, IsSucces = false, Message = "Daxil olunan məlumatlar yanlışdır." }); }
public async Task <IActionResult> Login([FromBody] SellerLoginDto loginCreds) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _repo.Login(loginCreds); if (result.IsSucces) { var returnDto = new SellerReturnDto() { Credentials = result.Content, Token = result.Message }; return(Ok(returnDto)); } return(Unauthorized(loginCreds)); }