Added header
This commit is contained in:
@@ -40,6 +40,7 @@ db.run(`CREATE TABLE IF NOT EXISTS games (
|
|||||||
// Registration route
|
// Registration route
|
||||||
app.post('/register', async (req, res) => {
|
app.post('/register', async (req, res) => {
|
||||||
const { username, email, password } = req.body;
|
const { username, email, password } = req.body;
|
||||||
|
console.log("Trying to Register: ", username);
|
||||||
try {
|
try {
|
||||||
const hashedPassword = await bcrypt.hash(password, 10);
|
const hashedPassword = await bcrypt.hash(password, 10);
|
||||||
const stmt = db.prepare('INSERT INTO users (username, email, password) VALUES (?, ?, ?)');
|
const stmt = db.prepare('INSERT INTO users (username, email, password) VALUES (?, ?, ?)');
|
||||||
@@ -58,6 +59,7 @@ app.post('/register', async (req, res) => {
|
|||||||
// Login route
|
// Login route
|
||||||
app.post('/login', (req, res) => {
|
app.post('/login', (req, res) => {
|
||||||
const { username, password } = req.body;
|
const { username, password } = req.body;
|
||||||
|
console.log("Trying to Login: ", username);
|
||||||
db.get('SELECT * FROM users WHERE username = ?', [username], async (err, row) => {
|
db.get('SELECT * FROM users WHERE username = ?', [username], async (err, row) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return res.status(500).json({ error: 'Internal server error' });
|
return res.status(500).json({ error: 'Internal server error' });
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ function App() {
|
|||||||
|
|
||||||
const showPopup = (message) => {
|
const showPopup = (message) => {
|
||||||
setPopupMessage(message);
|
setPopupMessage(message);
|
||||||
setTimeout(() => setPopupMessage(''), 3000); // Popup disappears after 3 seconds
|
setTimeout(() => setPopupMessage(''), 3000);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -9,12 +9,13 @@ const Header = ({ isLoggedIn }) => {
|
|||||||
<li style={styles.navItem}>
|
<li style={styles.navItem}>
|
||||||
<Link to="/" style={styles.navLink}>Home</Link>
|
<Link to="/" style={styles.navLink}>Home</Link>
|
||||||
</li>
|
</li>
|
||||||
<li style={styles.navItem}>
|
{!isLoggedIn && (
|
||||||
|
<><li style={styles.navItem}>
|
||||||
<Link to="/login" style={styles.navLink}>Login</Link>
|
<Link to="/login" style={styles.navLink}>Login</Link>
|
||||||
</li>
|
</li><li style={styles.navItem}>
|
||||||
<li style={styles.navItem}>
|
|
||||||
<Link to="/register" style={styles.navLink}>Register</Link>
|
<Link to="/register" style={styles.navLink}>Register</Link>
|
||||||
</li>
|
</li></>
|
||||||
|
)}
|
||||||
{isLoggedIn && (
|
{isLoggedIn && (
|
||||||
<li style={styles.navItem}>
|
<li style={styles.navItem}>
|
||||||
<Link to="/profile" style={styles.navLink}>Profile</Link>
|
<Link to="/profile" style={styles.navLink}>Profile</Link>
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ function Home({ isLoggedIn, setIsLoggedIn }) {
|
|||||||
<div className="button-group">
|
<div className="button-group">
|
||||||
<button className="btn" onClick={() => navigate('/start-game')}>Start Game</button>
|
<button className="btn" onClick={() => navigate('/start-game')}>Start Game</button>
|
||||||
<button className="btn" onClick={() => navigate('/join-game')}>Join Game</button>
|
<button className="btn" onClick={() => navigate('/join-game')}>Join Game</button>
|
||||||
<button className="btn" onClick={() => navigate('/continue-game')}>Continue Game</button>
|
|
||||||
<button className="btn" onClick={handleLogout}>Logout</button>
|
<button className="btn" onClick={handleLogout}>Logout</button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user