コード例 #1
0
        public async Task <IActionResult> Login([FromBody] RequestAuth request)
        {
            try
            {
                ResponseLogin responseLogin = new ResponseLogin();
                var           admin         = await _administratorService.Auth(request.Email, request.Password);

                var resident = await _residentService.Auth(request.Email, request.Password);

                if (admin == null && resident == null)
                {
                    UnauthorizedResponse();
                    return(new ObjectResult(response));
                }

                if (admin != null)
                {
                    responseLogin.User     = admin;
                    responseLogin.UserType = "ADMINISTRADOR";
                }
                else
                {
                    responseLogin.User     = admin;
                    responseLogin.UserType = "ADMINISTRADOR";
                }
                OkResponse(responseLogin);
                return(new ObjectResult(response));
            }
            catch (Exception e)
            {
                InternalServerErrorResponse(e.Message);
                return(new ObjectResult(response));
            }
        }