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
70 changes: 52 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,65 @@

![alt text](image.png)

## How to build
RNCP Planner is a helper tool for 42 students. At 42, progression is project-based: each validated project grants XP, and XP increases your level. This project lets you simulate planned project validations to estimate your future level and track your RNCP progression.

### Development
## Running RNCP Planner locally

1. Edit `flask/.env` and set `CLIENT_ID`, `CLIENT_SECRET`, `SECOND_CLIENT_SECRET`, and `REDIRECT_URI`
2. Replace the redirect url in the environment.ts
3. Execute:
<!-- <details> -->
<summary>Click to expand local setup instructions</summary>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The opening <details> tag is commented out on line 9, leaving <summary> orphaned and breaking the expandable accordion rendering in Markdown. Either uncomment <details> and </details> (line 66), or remove <summary>.


### Prerequisites

Before you begin, ensure you have the following installed on your system:

- [Docker](https://www.docker.com/)

### 1. Create a 42 API key

To use 42 OAuth and retrieve user projects, you must create an API key from the 42 intra.

1. Visit the 42 API [OAuth page](https://profile.intra.42.fr/oauth/applications).
2. Create a new application and use the following callback URL:

```text
http://localhost:3000/auth/callback/42

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The callback URL should point to /auth/callback rather than /auth/callback/42 to match the standard application route.

```

### 2. Configure environment variables

Create or edit `flask/.env` and fill it with the variables used by this project.

#### Example `flask/.env` file

```env
# UID of your 42 OAuth application
CLIENT_ID="u-s4t2ud..."

# Secret of your 42 OAuth application
CLIENT_SECRET="s-s4t2ud..."

# next secret
SECOND_CLIENT_SECRET="s-s4t2ud..."

# Must match your 42 OAuth application callback URL
REDIRECT_URI="http://localhost:3000/auth/callback/42"
```

> [!TIP]
> For local deployment, `CLIENT_ID`, `CLIENT_SECRET`, `SECOND_CLIENT_SECRET` and `REDIRECT_URI` are required.

### 3. Run RNCP Planner

With everything set up, run:

```bash
docker compose run angular npm install
docker compose up -d
```

### Production
Access the app at http://localhost:3000.

0. Edit flask/.env
1. Exec:
```bash
docker compose run angular sh -c "rm -rf node_modules && npm install && ng build"
```
> [!NOTE]
> If recent JSON/config changes do not appear immediately, force a browser hard refresh (`Ctrl+Shift+R`).

2. Uncomment the prod server on nginx.conf
2.1 Set SSL certificates
3. Replace redirect url in the environment.ts
4. Exec:
```bash
docker compose up -d nginx flask
```
<!-- </details> -->
4 changes: 4 additions & 0 deletions angular/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ export const routes: Routes = [
path: 'auth/callback',
component: LoginComponent,
},
{
path: 'auth/callback/:campusId',

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding :campusId here appears to be a workaround for setting the redirect URI to /auth/callback/42. 42 refers to the school/provider, not a campus ID parameter. The standard callback route is /auth/callback.

component: LoginComponent,
},
];
9 changes: 4 additions & 5 deletions angular/src/app/login/login.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { environment } from '../../environments/environment.development';
import { environment } from '../../environments/environment';
import { AuthService } from '../services/auth.service';
import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
Expand All @@ -13,14 +13,14 @@ import { TranslateModule } from '@ngx-translate/core';
styleUrl: './login.component.css',
})
export class LoginComponent implements OnInit {
auth_url = environment.auth_url;
repo_url = 'https://github.com/d-r-e/rncp';
auth_url = environment.auth_url;
repo_url = 'https://github.com/d-r-e/rncp';

constructor(
private route: ActivatedRoute,
private router: Router,
private authService: AuthService
) {}
) { }

ngOnInit(): void {
// Redirect to home if already logged in
Expand All @@ -32,7 +32,6 @@ export class LoginComponent implements OnInit {
this.route.queryParams.subscribe(params => {
if (params['code']) {
this.authService.login(params['code']);
this.router.navigate(['/rncp']);
}
});
}
Expand Down
Loading