public IActionResult Login([FromBody] LoginDto loginDto) { var instructor = _service.Login(loginDto.UserName, loginDto.Password); if (instructor == null) { return(Unauthorized()); } // var instructorDto = new InstructorDto // { // Id = instructor.Id, // Name = instructor.User.Name, // Surname = instructor.User.Surname, // Username = instructor.User.UserName, // Email = instructor.User.Email, // DepartmentName = instructor.Department.Name, //Token = CreateToken(instructor) //}; var instructorDto = _mapper.Map <MemberDto>(instructor); instructorDto.Role = "instructor"; instructorDto.Token = CreateToken(instructor); return(Ok(instructorDto)); }
public IActionResult Login([FromBody] LoginDto loginDto) { var instructor = _service.Login(loginDto.Email, loginDto.Password); if (instructor == null) { return(Unauthorized()); } var instructorDto = _mapper.Map <InstructorDto>(instructor); instructorDto.Token = CreateToken(instructor); return(Ok(instructorDto)); }