Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gdd-sigma-poc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Guillaume WANG
gdd-sigma-poc
Commits
c4946d16
Commit
c4946d16
authored
7 years ago
by
Anatole ROMON
Browse files
Options
Downloads
Patches
Plain Diff
je passe l'objet user au code LDAP a présent
parent
cb9c5319
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/graphql/schema.js
+18
-8
18 additions, 8 deletions
src/graphql/schema.js
src/server.js
+8
-3
8 additions, 3 deletions
src/server.js
with
26 additions
and
11 deletions
src/graphql/schema.js
+
18
−
8
View file @
c4946d16
...
...
@@ -55,7 +55,7 @@ const typeDefs = `
*/
const
getAllVisibleGroups
=
(
user
)
=>
{
return
listGroups
(
user
.
id
).
then
(
group_ids
=>
{
return
listGroups
(
user
.
u
id
,
user
).
then
(
group_ids
=>
{
var
membered_groups
=
qb
=>
qb
.
select
().
from
(
'
groups
'
).
whereIn
(
'
uid
'
,
group_ids
.
concat
([
'
kes
'
]));
/* membered_groups est un callback qui reçoit un argument qb représentant un objet de requête (un truc qui s'utilise comme knex())
* et effectue dessus la requête pour obtenir une table de tous les groupes dont user est membre
...
...
@@ -91,7 +91,7 @@ const getGroupIfVisible = (user, uid) => {
* @return {Promise} Retour de requête knex. Promise qui renvera une liste de tous les utilisateurs ayant droit d'admin sur le groupe
*/
const
getUsersWithAdminRights
=
(
uid
)
=>
{
return
listAdmins
(
uid
);
return
listAdmins
(
uid
,
user
);
};
/**
...
...
@@ -101,9 +101,15 @@ const getUsersWithAdminRights = (uid) => {
* @return {Promise} Retour de requête knex. Promise qui renvera une liste de tous les utilisateurs ayant droit d'admin sur le groupe
*/
const
getAvailableGroupUID
=
(
initialUID
)
=>
{
let
rasUID
=
initialUID
;
rasUID
.
replace
(
'
'
,
'
_
'
);
rasUID
.
replace
(
/
\W
/g
,
''
);
let
rasUID
=
initialUID
.
replace
(
'
'
,
'
_
'
).
replace
(
/
\W
/g
,
''
);
return
knex
.
from
(
'
groups
'
).
where
(
'
uid
'
,
rasUID
).
then
(
res
=>
{
if
(
res
.
length
==
0
){
return
(
rasUID
);
}
else
{
return
(
getAvailableGroupUID
(
rasUID
+
'
n
'
));
}
});
return
rasUID
;
};
const
createGroupIfLegal
=
(
user
,
args
)
=>
{
...
...
@@ -115,9 +121,10 @@ const createGroupIfLegal = (user, args) => {
return
admins
.
then
(
admin_list
=>
{
if
(
admin_list
.
indexOf
(
user
.
id
)
==
-
1
)
throw
"
illegal request : you must have admin rights over a group to create a subgroup of that group
"
;
return
(
getAvailableGroupUID
(
args
.
uid
).
then
(
res
=>
{
}));
});
};
const
resolvers
=
{
...
...
@@ -152,7 +159,10 @@ const resolvers = {
Mutation
:
{
createGroup
:
(
obj
,
args
,
context
)
=>
{
return
createGroupIfLegal
(
context
.
user
,
args
);
getAvailableGroupUID
(
"
subaïsse
"
).
then
(
res
=>
console
.
log
(
res
));
getAvailableGroupUID
(
"
br
"
).
then
(
res
=>
console
.
log
(
res
));
return
null
;
//return createGroupIfLegal(context.user, args);
}
}
};
...
...
This diff is collapsed.
Click to expand it.
src/server.js
+
8
−
3
View file @
c4946d16
...
...
@@ -35,17 +35,22 @@ server.use(morgan('dev'));
server
.
use
(
'
/graphql
'
,
bodyParser
.
json
(),
cors
(),
graphqlExpress
(
req
=>
{
let
uid
;
let
password
;
try
{
uid
=
"
anatole.romon
"
;
uid
=
"
louis.vanneau
"
;
password
=
"
mythe
"
//uid = req.session.id;
//password = req.session.password;
}
catch
(
err
)
{
uid
=
"
1
"
;
uid
=
"
louis.vanneau
"
;
password
=
"
mythe
"
}
return
{
schema
:
schema
,
context
:
{
user
:
{
id
:
uid
}}
context
:
{
user
:
{
u
id
:
uid
,
password
:
password
}}
};
}));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment