Skip to content

Commit

Permalink
fix: mantenimiento de código obsoleto al realizar la autenticación
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasrival committed May 23, 2024
1 parent c32071c commit c393a70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 36 deletions.
37 changes: 3 additions & 34 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,9 @@ const App = () => {

useEffect(() => {
if (!ALLOWED_ROUTES.includes(window.location.pathname)) {
axios.interceptors.response.use(
response => response,
async error => {
if (error.response) {
if (error.response.status === 401 && error.response.data?.message) {
window.location.href = error.response.data.message
delete error.response.data.message
}
// The response was made and the server responded with a
// status code that is outside the 2xx range.
Sentry.setTags({
data: error.response.data,
headers: error.response.headers,
status_code: error.response.status,
})
} else if (error.request) {
// The request was made but no response was received
Sentry.setTag('request', error.request)
} else {
// Something happened while preparing the request that threw an Error
Sentry.setTag('message', error.message)
}
if (error?.response?.status !== 401) Sentry.captureException(error)
return Promise.reject(error)
}
)
if (!keycloak.authenticated) {
keycloak.login()
}
} else {
setError(false)
}
Expand Down Expand Up @@ -224,14 +201,6 @@ const App = () => {
<Route>
<Redirect to='/' />
</Route>

{/* <Route exact path='/settingsnew'>
<SettingsNew />
</Route>
<Route exact path='/home'>
<Home />
</Route> */}
</Switch>
</div>
</RoomsProvider>
Expand Down
5 changes: 3 additions & 2 deletions src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const Layout: React.FC<Props> = ({ children, isLoading }) => {
const { keycloak } = useKeycloak();
const { pathname } = useLocation()
const main = useRef<HTMLElement>(null)
const logout = () => keycloak.logout()

const [mobileOpen, setMobileOpen] = useState(false)
const [waitingroomOpen, setWaitingroomOpen] = useState(false)
Expand Down Expand Up @@ -278,7 +279,7 @@ const Layout: React.FC<Props> = ({ children, isLoading }) => {
className='block w-full px-4 py-2 text-sm leading-5 text-left text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900'
role='menuitem'
style={{ cursor: "pointer" }}
onClick={() => keycloak.logout()}
onClick={logout}
>
Cerrar Sesión
</button>
Expand Down Expand Up @@ -518,7 +519,7 @@ const Layout: React.FC<Props> = ({ children, isLoading }) => {
<button
className='block w-full px-4 py-2 text-sm leading-5 text-left text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900'
role='menuitem'
onClick={() => keycloak.logout()}
onClick={logout}
>
Cerrar Sesión
</button>
Expand Down

0 comments on commit c393a70

Please sign in to comment.