Skip to content
Merged
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ This repository holds code for BCAN. We are developing a tabular-focused website
# Welcome to BCAN..
2. cd backend, npm install, init environment, npm run start
3. cd frontend, npm install, init environment, npm run dev
4. Make sure the fill out the template env for the frontend and backend.


## Commands
1. node canIMerge.js --> Will your code pass on code style check, run node canIMerge.js --help for options
2. node bcan-doctor.js --> Will pop out relevant functions, classes, etc. documentation for the backend in 'architecture.md'

## Misc

Frontend should run on localhost:5173 and localhost:3001


Here's a fun GIF to get started!

*GIF from [GIPHY](https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExY2VjNWJ4dnBnNWt2ajcxdmdkazJkY2YxYXk4b3J4a3BqN3dveWdqeSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/LHZyixOnHwDDy/giphy.gif)*
9 changes: 8 additions & 1 deletion backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ async function bootstrap() {
});

const app = await NestFactory.create(AppModule);
app.enableCors();
// cors enabled for the local frontend dev server
app.enableCors({
origin: 'http://localhost:5173', // Your frontend URL
credentials: true, // Required for cookies/credentials
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
});

await app.listen(3001);
}
dotenv.config();
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,25 @@ import { useNavigate } from "react-router-dom";
import "./external/bcanSatchel/mutators";
import "./styles/button.css"


/**
* Registered users can log in here
*/
const Login = observer(() => {
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const navigate = useNavigate();
const { login } = useAuthContext();
const { login,isAuthenticated } = useAuthContext();

const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
try {
await login(username, password);
if (isAuthenticated){
navigate("/grant-info");
} else {
alert('Login failed. Please check your credentials.');
}
} catch (error) {
console.error("Error during login:", error);
alert("An error occurred while logging in. Please try again later.");
Expand Down