コード例 #1
0
        public async Task <ActionResult <AdminInstructorResponse> > Authenticate([FromBody] Login login)
        {
            var response = new AdminInstructorResponse();

            var instructor = await _instructorService.Authenticate(login.UniqueIdentifier, login.Password);

            if (instructor != null)
            {
                response.Type       = "Instructor";
                response.Instructor = instructor;
                return(Ok(response));
            }

            var admin = await _adminService.Authenticate(login.UniqueIdentifier, login.Password);

            if (admin != null)
            {
                response.Type  = "Admin";
                response.Admin = admin;
                return(Ok(response));
            }

            return(BadRequest(new { message = "Invalid Credentials" }));
        }