Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions components/AddTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ export default function AddTask() {
* @todo 1. Send the request to add the task to the backend server.
* @todo 2. Add the task in the dom.
*/




const addTask = async() => {


try{
await axios.post("todo/create/",{title:task},options)
}

catch(err){
console.log(err)
}

};
};

return (
Expand Down
16 changes: 16 additions & 0 deletions middlewares/auth_required.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/***
* @todo Redirect the user to login page if token is not present.
*/
import { useEffect } from 'react';
import { useRouter } from 'next/router';
import { useAuth } from '../context/auth';

const useAuthProtection = () => {
const router = useRouter();
const { token } = useAuth();

useEffect(() => {
if (!token) {
router.push('/login');
}
}, [token, router]);

return token;
};
Loading