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