-
Notifications
You must be signed in to change notification settings - Fork 0
Sistema de Login y Registro con Autenticación JWT #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JMLTUnderCode
wants to merge
23
commits into
main
Choose a base branch
from
login-register-system
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
f695619
Se hace uso del estado global Auth para realizar el login, se hable u…
JMLTUnderCode 028ea64
Se implementa una logica de proteccion de rutas en caso de que no se …
JMLTUnderCode b90ac7f
Actualizacion de nombre el custom hook useAuthentication
JMLTUnderCode e3ef8c2
Inclusion e instalacion de CORS para url de desarrollo
JMLTUnderCode 24b1d5f
Se incluye context para Authenticacion. Se modifica el nombre del arc…
JMLTUnderCode d68bdf6
Actualizacion de nombre de context
JMLTUnderCode b86c6fc
Se incluye custom hooks para uso de provider de authenticacion
JMLTUnderCode 5a3f633
Se incluye pagina web principal con un titulo, texto de verificacion …
JMLTUnderCode 735890f
Actualizacion general de nombre de archivos. Cambio de sitio para log…
JMLTUnderCode 476f22a
Actualizacion de tipos relacionado con LoginView y sus acciones. Incl…
JMLTUnderCode e6893f6
Se implementa React Router para navegacion entre componentes. Se prot…
JMLTUnderCode 7222008
Se aplica provider de authenticacion a toda la aplicacion.
JMLTUnderCode f60ffac
Instalacion de react router dom para uso de React Router
JMLTUnderCode 2aeb75b
Instalacion de CORS
JMLTUnderCode cb2ae3c
Inclusion de codigo comentado para el uso de prueba local de peticion…
JMLTUnderCode 7d28e9d
Implementacion de reducer y provider para authenticacion de usuarios.…
JMLTUnderCode d8f1425
Se implementa handler de registro que de ser exitoso se reset estado …
JMLTUnderCode c96f67b
Se envuelve cada tests en su respectivo authentication provider y Mem…
JMLTUnderCode 08a13d3
Se comenta que cors debe ir siempre primero en la lista de middleware
JMLTUnderCode 1fea3e3
tab por spaces
JMLTUnderCode c9dcaa6
Manejo de catch por consola
JMLTUnderCode 6baee63
Eliminacion de comentario de url antigua
JMLTUnderCode 2a259c9
Elimnacion de comentario
JMLTUnderCode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,24 @@ | ||
| import './styles/App.css' | ||
| import { BrowserRouter, Routes, Route } from 'react-router-dom'; | ||
| import { ProtectedRoute } from './components/ProtectedRoute'; | ||
| import { StartPage } from './pages/StartPage'; | ||
| import { MainPage } from './pages/MainPage'; | ||
| import { Footer } from './components/Footer'; | ||
|
|
||
| export function App() { | ||
| return ( | ||
| <div className="App"> | ||
| <StartPage /> | ||
| <Footer /> | ||
| </div> | ||
| return ( | ||
| <BrowserRouter basename="/Clontube/"> | ||
| <div className="App"> | ||
| <Routes> | ||
| <Route path="/" element={<StartPage />} /> | ||
| <Route path="/main/" element={ | ||
| <ProtectedRoute> | ||
| <MainPage /> | ||
| </ProtectedRoute> | ||
| } /> | ||
| </Routes> | ||
| <Footer /> | ||
| </div> | ||
| </BrowserRouter> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { useNavigate } from "react-router-dom"; | ||
| import React, { useEffect } from "react"; | ||
| import { useAuthentication } from "../hooks/useAuthentication"; | ||
|
|
||
| export function ProtectedRoute({ children }: { children: React.ReactNode }) { | ||
| const navigate = useNavigate(); | ||
| const { AUTH_STATE } = useAuthentication(); | ||
|
|
||
| useEffect(() => { | ||
| if (AUTH_STATE.isAuthenticated === false) { | ||
| navigate("/"); | ||
| } | ||
| }, [AUTH_STATE.isAuthenticated, navigate]); | ||
|
|
||
| return <>{children}</>; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { createContext } from 'react'; | ||
| import type { AuthContextType } from '../utils/types'; | ||
|
|
||
| export const AuthenticationContext = createContext<AuthContextType | undefined>(undefined); |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { useContext } from 'react'; | ||
| import { AuthenticationContext } from '../contexts/AuthenticationContext'; | ||
|
|
||
| export function useAuthentication() { | ||
| const context = useContext(AuthenticationContext); | ||
| if (!context) { | ||
| throw new Error('useAuthentication must be used within a AuthenticationProvider'); | ||
| } | ||
| return context; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { useNavigate } from 'react-router-dom'; | ||
| import { useAuthentication } from '../hooks/useAuthentication'; | ||
|
|
||
| export function MainPage() { | ||
| const navigate = useNavigate(); | ||
| const { AUTH_STATE, logout } = useAuthentication(); | ||
|
|
||
| const handleLogout = () => { | ||
| logout(); | ||
| navigate('/'); | ||
| } | ||
| return ( | ||
| <div> | ||
| <h2>Main Page</h2> | ||
| <p>Welcome, {AUTH_STATE.user ? AUTH_STATE.user.username : 'Guest'}!</p> | ||
| <button className="btn" onClick={handleLogout}>Logout</button> | ||
| </div> | ||
| ) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty catch and error handling blocks provide no feedback to users. These should implement proper error handling with user-facing messages or logging.