Skip to content
Snippets Groups Projects
Commit b33ec442 authored by Wilson JALLET's avatar Wilson JALLET :money_with_wings:
Browse files

Updated GraphQL and updated admin page

parent f934cd62
No related branches found
No related tags found
No related merge requests found
...@@ -37,27 +37,31 @@ input.form-control:focus { ...@@ -37,27 +37,31 @@ input.form-control:focus {
} }
.button { .button {
margin-top: 0.7em;
margin-bottom: 0.7em;
display: block; display: block;
color: white; color: white;
min-width: 120px; min-width: 100px;
height: 30px; height: 30px;
background-color: rgba(0, 2, 138, 0.767); background-color: rgba(0, 2, 138, 0.767);
border: solid 1px rgba(117, 117, 117, 0.226); border: solid 1px rgba(117, 117, 117, 0.226);
border-radius: 4px; border-radius: 4px;
} }
div.button { a.button {
display: block; display: block;
text-align: center; text-align: center;
font-size: 11pt; font-size: 10pt;
width: 120px;
}
button a {
color: white; color: white;
text-decoration: none; text-decoration: none;
} }
.button-small {
width: 100px;
}
.form-group button { .form-group button {
margin-top: 0; margin-top: 0;
margin-left: 0.6em margin-left: 0.6em
......
...@@ -133,7 +133,7 @@ const createSubgroup = (user, args) => { ...@@ -133,7 +133,7 @@ const createSubgroup = (user, args) => {
return getGroupIfVisible(user, rasUID); return getGroupIfVisible(user, rasUID);
}); });
})); }));
} };
/** /**
* @summary Créé un groupe si les arguments sont tous valides et l'utilisateur est authorisé * @summary Créé un groupe si les arguments sont tous valides et l'utilisateur est authorisé
...@@ -205,9 +205,9 @@ const resolvers = { ...@@ -205,9 +205,9 @@ const resolvers = {
AdminMutation: { AdminMutation: {
isAdmin: (obj, args, context) => { isAdmin: (obj, args, context) => {
return true; return true;
}, },
createSubgroup: (obj, args, context) => { createSubgroup: (obj, args, context) => {
args.parentuid = obj.groupUID; args.parentuid = obj.groupUID;
return createSubgroup(context.user, args); return createSubgroup(context.user, args);
......
...@@ -5,6 +5,7 @@ const RootTypes = ` ...@@ -5,6 +5,7 @@ const RootTypes = `
group(uid: ID) : Group group(uid: ID) : Group
user(uid: ID) : [User] user(uid: ID) : [User]
allEvents: [Event] allEvents: [Event]
allPosts: [Post]
} }
type Mutation { type Mutation {
...@@ -83,36 +84,44 @@ const Group = ` ...@@ -83,36 +84,44 @@ const Group = `
uid: ID uid: ID
name: String name: String
website: String website: String
createdAt: String createdAt: String!
updatedAt: String updatedAt: String!
description: String description: String
school: String school: String
parentuid: String parentuid: String
} }
`; `;
const Post = `
# Publications
interface Post {
id: ID!
title: String!
createdAt: String!
updatedAt: String!
# Auteurs de la publication
author: [Group]
description: String
}
`;
const Event = ` const Event = `
# Événements # Événements
type Event { type Event implements Post {
id: ID!
# Intitulé de l'événement # Intitulé de l'événement
title: String! title: String!
# Lieu de l'événement # Lieu de l'événement
location: String location: String
datetime: String! createdAt: String!
# Groupes organisateurs updatedAt: String!
groups: [Group] startTime: String!
endTime: String!
# Organisateurs
author: [Group]
# Personnes qui y participent # Personnes qui y participent
participants: [User] participants: [User]
} description: String
`;
const Post = `
# Publication
type Post {
title: String!
uid: ID!
# Groupe auteur de la publication
author: Group
} }
`; `;
......
/** /**
* @file Entry point de webpack * @file Point d'entrée de webpack
*/ */
import server from './server'; import server from './server';
import colors from 'colors'; import colors from 'colors';
......
...@@ -2,16 +2,19 @@ ...@@ -2,16 +2,19 @@
* @file Cree le serveur express avec tous les middleware qui vont bien * @file Cree le serveur express avec tous les middleware qui vont bien
*/ */
import express from 'express'; import express from 'express';
import schema from './graphql/schema';
import { express as graphqlVoyager } from 'graphql-voyager/middleware';
import { graphqlExpress, graphiqlExpress } from 'graphql-server-express';
import flash from 'connect-flash';
import passport from 'passport';
import LdapStrategy from 'passport-ldapauth';
import fs from 'fs';
import session from 'express-session';
import bodyParser from 'body-parser'; import bodyParser from 'body-parser';
import favicon from 'serve-favicon'; import favicon from 'serve-favicon';
import morgan from 'morgan'; import morgan from 'morgan';
import path from 'path'; import path from 'path';
import cors from 'cors'; import cors from 'cors';
import schema from './graphql/schema';
import setupLdapAuth from './ldap/ldap_auth';
import { express as graphqlVoyager } from 'graphql-voyager/middleware';
import { graphqlExpress, graphiqlExpress } from 'graphql-server-express';
import flash from 'connect-flash';
const server = express(); const server = express();
...@@ -24,7 +27,34 @@ server.use(bodyParser.urlencoded({ ...@@ -24,7 +27,34 @@ server.use(bodyParser.urlencoded({
/** /**
* @description Configuration authentification * @description Configuration authentification
*/ */
setupLdapAuth(server); let configPath = path.resolve('./', 'ldap_config.json');
let config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
passport.use(new LdapStrategy({
server: {
url: config.ldap.server,
searchBase: config.ldap.searchBase,
searchFilter: config.ldap.searchFilter
}
}
));
// Définit les paramètres de stockage des sessions.
server.use(session({
secret: config.sessionSecret,
resave: true,
saveUninitialized: false
}));
server.use(passport.initialize());
server.use(passport.session());
passport.serializeUser(function (user, done) {
done(null, user);
});
passport.deserializeUser(function (user, done) {
done(null, user);
});
/** /**
* @description Cache le fait que l'application tourne sous Express dans le header HTTP. * @description Cache le fait que l'application tourne sous Express dans le header HTTP.
...@@ -53,7 +83,7 @@ server.use('/graphql', bodyParser.json(), cors(), ...@@ -53,7 +83,7 @@ server.use('/graphql', bodyParser.json(), cors(),
uid = req.session.passport.user.uid; uid = req.session.passport.user.uid;
password = "mythe"; password = "mythe";
} catch (err) { } catch (err) {
uid = "anonymous"; uid = "quentin.chevalier";
password = ""; password = "";
} }
......
...@@ -14,13 +14,12 @@ block content ...@@ -14,13 +14,12 @@ block content
input.form-control(type="search", name="columns") input.form-control(type="search", name="columns")
button.form-control(type="submit",class="button") Recherche/<em>Search</em> button.form-control(type="submit",class="button") Recherche/<em>Search</em>
| |
h2 GraphiQL h2 GraphiQL and Voyager
p GraphiQL is an interactive environment to make GraphQL p GraphiQL is an interactive environment to make GraphQL
| requests to the database. | requests to the database.
div(class="button") p GraphQL Voyager is an application that displays the GraphQL schema as an actual graph.
a(href="/graphiql") Check it out. a(class="button button-small",href="/graphiql") GraphiQL
div(class="button") a(class="button button-small",href="/voyager") Voyager
a(href="/voyager") Check it out.
| |
p Currently logged in as: #{userName}. p Currently logged in as: #{userName}.
form(action="/logout", method="post") form(action="/logout", method="post")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment