Loading...
;
+};
+
+export default OAuthCallback;
diff --git a/client/src/pages/AuthSelection/SimpleLogin.tsx b/client/src/pages/AuthSelection/SimpleLogin.tsx
index be93f8c..ce5f475 100644
--- a/client/src/pages/AuthSelection/SimpleLogin.tsx
+++ b/client/src/pages/AuthSelection/SimpleLogin.tsx
@@ -33,7 +33,7 @@ const SimpleLogin: React.FC = () => {
return;
}
else {
- navigate("/teacher/Dashboard")
+ navigate("/")
}
};
diff --git a/client/src/pages/Home/Home.tsx b/client/src/pages/Home/Home.tsx
index bc0cfc9..b2abf1f 100644
--- a/client/src/pages/Home/Home.tsx
+++ b/client/src/pages/Home/Home.tsx
@@ -6,13 +6,6 @@ import { Link } from 'react-router-dom';
const Home: React.FC = () => {
return (
-
-
-
-
-
-
-
diff --git a/client/src/services/ApiService.tsx b/client/src/services/ApiService.tsx
index 55dccb7..13c9c34 100644
--- a/client/src/services/ApiService.tsx
+++ b/client/src/services/ApiService.tsx
@@ -32,7 +32,7 @@ class ApiService {
}
// Helpers
- private saveToken(token: string): void {
+ public saveToken(token: string): void {
const now = new Date();
const object = {
diff --git a/server/app.js b/server/app.js
index ecf1319..c5d3e68 100644
--- a/server/app.js
+++ b/server/app.js
@@ -68,7 +68,6 @@ app.use(session({
}));
authManager = new AuthManager(app)
-
app.use(errorHandler)
// Start server
diff --git a/server/auth/modules/passport-providers/oauth.js b/server/auth/modules/passport-providers/oauth.js
index a38dc44..7479c0c 100644
--- a/server/auth/modules/passport-providers/oauth.js
+++ b/server/auth/modules/passport-providers/oauth.js
@@ -56,6 +56,8 @@ class PassportOAuth {
(req, res) => {
if (req.user) {
res.json(req.user)
+ //const redirectUrl = `http://your-frontend-url.com/oauth/callback?user=${encodeURIComponent(req.user)}`;
+ //res.redirect(redirectUrl);
console.info(`L'utilisateur '${req.user.name}' vient de se connecter`)
} else {
res.status(401).json({ error: "L'authentification a échoué" });
diff --git a/server/auth/modules/passportjs.js b/server/auth/modules/passportjs.js
index e65b53c..a2e16bb 100644
--- a/server/auth/modules/passportjs.js
+++ b/server/auth/modules/passportjs.js
@@ -1,5 +1,6 @@
const fs = require('fs');
var passport = require('passport')
+var authprovider = require('../../models/authProvider')
class PassportJs{
constructor(authmanager,settings){
@@ -9,10 +10,10 @@ class PassportJs{
this.endpoint = "/api/auth"
}
- registerAuth(expressapp){
+ async registerAuth(expressapp){
expressapp.use(passport.initialize());
expressapp.use(passport.session());
-
+
for(const p of this.providers){
for(const [name,provider] of Object.entries(p)){
if(!(provider.type in this.registeredProviders)){
@@ -20,6 +21,9 @@ class PassportJs{
}
try{
this.registeredProviders[provider.type].register(expressapp,passport,this.endpoint,name,provider)
+
+ const auth_id = `passportjs_${provider.type}_${name}`
+ authprovider.create(auth_id)
} catch(error){
console.error(`La connexion ${name} de type ${provider.type} n'as pu être chargé.`)
}
@@ -35,7 +39,7 @@ class PassportJs{
});
}
- registerProvider(providerType){
+ async registerProvider(providerType){
try{
const providerPath = `${process.cwd()}/auth/modules/passport-providers/${providerType}.js`
const Provider = require(providerPath);
@@ -45,6 +49,15 @@ class PassportJs{
console.error(`Le type de connexion '${providerType}' n'as pas pu être chargé dans passportjs.`)
}
}
+
+
+ register(){
+
+ }
+
+ authenticate(){
+
+ }
}
diff --git a/server/models/authProvider.js b/server/models/authProvider.js
new file mode 100644
index 0000000..52f7b94
--- /dev/null
+++ b/server/models/authProvider.js
@@ -0,0 +1,30 @@
+const db = require('../config/db.js')
+const { ObjectId } = require('mongodb');
+
+class AuthProvider {
+ constructor(name) {
+ this._id = new ObjectId();
+ this.name = name;
+ }
+
+ async create(name) {
+ await db.connect()
+ const conn = db.getConnection();
+
+ const collection = conn.collection('authprovider');
+
+ const existingauth = await collection.findOne({ name:name });
+
+ if(foldersCollection){
+ return existingauth._id;
+ }
+
+ const newProvider = {
+ name:name
+ }
+ const result = await foldersCollection.insertOne(newProvider);
+ return result.insertedId;
+ }
+}
+
+module.exports = new AuthProvider;
\ No newline at end of file
diff --git a/server/models/authUserAssociation.js b/server/models/authUserAssociation.js
new file mode 100644
index 0000000..65dc33e
--- /dev/null
+++ b/server/models/authUserAssociation.js
@@ -0,0 +1,14 @@
+const db = require('../config/db.js')
+const { ObjectId } = require('mongodb');
+
+
+class AuthUserAssociation {
+ constructor(authProviderId, authId, userId) {
+ this._id = new ObjectId();
+ this.authProvider_id = authProviderId;
+ this.auth_id = authId;
+ this.user_id = userId;
+ }
+ }
+
+module.exports = new AuthUserAssociation;
\ No newline at end of file
diff --git a/server/models/userAuthAssociation.js b/server/models/userAuthAssociation.js
new file mode 100644
index 0000000..8e12717
--- /dev/null
+++ b/server/models/userAuthAssociation.js
@@ -0,0 +1,13 @@
+const db = require('../config/db.js')
+const { ObjectId } = require('mongodb');
+
+
+class AuthUserAssoc {
+ constructor(authProviderId, authId, userId) {
+ this._id = new ObjectId();
+ this.authProvider_id = authProviderId;
+ this.auth_id = authId;
+ this.user_id = userId;
+ }
+ }
+
\ No newline at end of file