Index: reactapp/src/App.js
===================================================================
--- reactapp/src/App.js	(revision 800779d11fae3f904af95db61c2464778d067cf9)
+++ reactapp/src/App.js	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
@@ -2,20 +2,55 @@
 import SearchResults from "./Pages/SearchResults";
 import Login from "./Pages/Login";
-import { BrowserRouter, Routes, Route } from "react-router-dom";
+import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom";
 import Home from "./Pages/Home";
+import User from "./Pages/User";
+import { useEffect, useState, useMemo } from "react";
+import AuthApi from "./api/AuthApi";
+import Cookies from "js-cookie";
 
 export default function App() {
+  const [auth, setAuth] = useState(false);
+  const variableAuth = useMemo(() => ({ auth, setAuth }), [auth]);
+
+  const readCookie = () => {
+    const session = Cookies.get("JSESSIONID");
+    if (session) {
+      setAuth(true); // go stava true ako postoi takvo cookie (zasto auth=false na sekoe renderiranje)
+    }
+  };
+
+  useEffect(() => {
+    readCookie();
+  }, []);
+
+  const ProtectedRoute = ({ auth, children }) => {
+    if (!auth) {
+      return <Navigate to="/login" replace />;
+    }
+    return children;
+  };
+
   return (
-    <BrowserRouter>
-      <Routes>
-        <Route path="/" element={<Home />}>
-          <Route path="login" element={<Login />}></Route>
-          <Route path="professor">
-            <Route path=":professorId" element={<Professor />} />
+    <AuthApi.Provider value={variableAuth}>
+      <BrowserRouter>
+        <Routes>
+          <Route path="/" element={<Home />}>
+            <Route path="login" element={<Login />}></Route>
+            <Route path="professor">
+              <Route path=":professorId" element={<Professor />} />
+            </Route>
+            <Route path="search" element={<SearchResults />}></Route>
+            <Route
+              path="user"
+              element={
+                <ProtectedRoute auth={auth}>
+                  <User />
+                </ProtectedRoute>
+              }
+            ></Route>
           </Route>
-          <Route path="search" element={<SearchResults />}></Route>
-        </Route>
-      </Routes>
-    </BrowserRouter>
+        </Routes>
+      </BrowserRouter>
+    </AuthApi.Provider>
   );
 }
Index: reactapp/src/Components/Logout.js
===================================================================
--- reactapp/src/Components/Logout.js	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
+++ reactapp/src/Components/Logout.js	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
@@ -0,0 +1,16 @@
+import React, { useContext } from "react";
+import AuthApi from "../api/AuthApi";
+import Cookies from "js-cookie";
+
+function Logout() {
+  const { auth, setAuth } = useContext(AuthApi);
+
+  const handleLogout = () => {
+    setAuth(false);
+    Cookies.remove("JSESSIONID");
+  };
+
+  return <button onClick={handleLogout}>Одјави се</button>;
+}
+
+export default Logout;
Index: reactapp/src/Components/Search.js
===================================================================
--- reactapp/src/Components/Search.js	(revision 800779d11fae3f904af95db61c2464778d067cf9)
+++ reactapp/src/Components/Search.js	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
@@ -15,5 +15,5 @@
 
   useEffect(() => {
-    const url = `http://192.168.0.17:8080/public/professors/nameContains/${transliterate(
+    const url = `http://192.168.0.18:8080/public/professors/nameContains/${transliterate(
       query
     )}`;
Index: reactapp/src/Pages/Home.js
===================================================================
--- reactapp/src/Pages/Home.js	(revision 800779d11fae3f904af95db61c2464778d067cf9)
+++ reactapp/src/Pages/Home.js	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
@@ -20,4 +20,5 @@
       </a>{" "}
       <Search />
+      <div style={{ marginTop: "140px" }}></div>
       <Outlet />
     </MainWrapper>
Index: reactapp/src/Pages/Login.js
===================================================================
--- reactapp/src/Pages/Login.js	(revision 800779d11fae3f904af95db61c2464778d067cf9)
+++ reactapp/src/Pages/Login.js	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
@@ -1,7 +1,11 @@
-import React, { useRef, useState, useEffect } from "react";
+import React, { useRef, useState, useEffect, useContext } from "react";
+import { Navigate } from "react-router-dom";
+import AuthApi from "../api/AuthApi";
 import axios from "../api/axios";
+import Cookies from "js-cookie";
 const LOGIN_URL = "/login";
 
 const Login = () => {
+  const { auth, setAuth } = useContext(AuthApi);
   const userRef = useRef();
   const errRef = useRef();
@@ -10,13 +14,8 @@
   const [password, setPassword] = useState("");
   const [errMsg, setErrMsg] = useState("");
-  const [success, setSuccess] = useState(false);
 
   useEffect(() => {
     userRef.current.focus();
   }, []);
-
-  useEffect(() => {
-    setErrMsg("");
-  }, [username, password]);
 
   const handleSubmit = async (e) => {
@@ -33,17 +32,34 @@
       }
     );
+    if (!response.request.responseURL.includes("error")) {
+      // ako NE redirektira na /login?error
+      Cookies.set("JSESSIONID", response.data.sessionId);
+      setAuth(true);
+      setErrMsg("");
+    } else {
+      setErrMsg("Погрешно корисиничко име и/или лозинка");
+    }
+
     setUsername("");
     setPassword("");
-    setSuccess(true);
   };
 
-  return success ? (
+  const handleLogout = () => {
+    setAuth(false);
+    Cookies.remove("JSESSIONID");
+  };
+
+  return auth ? (
+    /*
     <div style={{ marginTop: "140px" }}>
       <h1>Успешна најава!</h1>
       <br />
       <p>
-        <a href="/">Оди на почетната страница</a>
+        <a href="/user">Оди на protected</a>
       </p>
+      <button onClick={handleLogout}>Одјави се</button>
     </div>
+    */
+    <Navigate to="/user" />
   ) : (
     <div style={{ marginTop: "140px" }}>
Index: reactapp/src/Pages/Professor.js
===================================================================
--- reactapp/src/Pages/Professor.js	(revision 800779d11fae3f904af95db61c2464778d067cf9)
+++ reactapp/src/Pages/Professor.js	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
@@ -18,5 +18,5 @@
 
   useEffect(() => {
-    const url = `http://192.168.0.17:8080/public/professor/${params.professorId}`;
+    const url = `http://192.168.0.18:8080/public/professor/${params.professorId}`;
 
     const fetchData = async () => {
Index: reactapp/src/Pages/User.js
===================================================================
--- reactapp/src/Pages/User.js	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
+++ reactapp/src/Pages/User.js	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
@@ -0,0 +1,17 @@
+import React, { useState, useContext } from "react";
+import AuthApi from "../api/AuthApi";
+
+import Logout from "../Components/Logout";
+
+function User() {
+  const { auth, setAuth } = useContext(AuthApi);
+
+  return (
+    <>
+      user page
+      <Logout />
+    </>
+  );
+}
+
+export default User;
Index: reactapp/src/api/AuthApi.js
===================================================================
--- reactapp/src/api/AuthApi.js	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
+++ reactapp/src/api/AuthApi.js	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
@@ -0,0 +1,5 @@
+import { createContext } from "react";
+
+const AuthApi = createContext();
+
+export default AuthApi;
Index: reactapp/src/api/axios.js
===================================================================
--- reactapp/src/api/axios.js	(revision 800779d11fae3f904af95db61c2464778d067cf9)
+++ reactapp/src/api/axios.js	(revision 6eba109d7d2a405c2c4bf11d744ceb4c8a56c9da)
@@ -2,4 +2,4 @@
 
 export default axios.create({
-  baseURL: "http://192.168.0.17:8080",
+  baseURL: "http://192.168.0.18:8080",
 });
