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
0df0b21e
Commit
0df0b21e
authored
7 years ago
by
Guillaume WANG
Browse files
Options
Downloads
Patches
Plain Diff
modified admin_router routing
parent
aa5441f9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/admin_view/admin_router.js
+16
-12
16 additions, 12 deletions
src/admin_view/admin_router.js
with
16 additions
and
12 deletions
src/admin_view/admin_router.js
+
16
−
12
View file @
0df0b21e
/**
* @file Ce fichier définit le routage d'URL au sein de l'interface du _backend_.
*
* Il définit la page de connexion `/`, le panneau administrateur `/admin` et l'API REST (`/db/:table?`)
* Il définit la page de connexion `/`, le panneau administrateur `/admin` et l'API REST \(`/db/:table?`)
* permettant de consulter la base de donnée interne à Sigma, via des requêtes construites avec Knex.
* @author manifold
*/
...
...
@@ -14,21 +13,24 @@ const router = express.Router();
let
port
=
process
.
env
.
PORT
||
3000
;
/**
* @description Le login se fait en POST. Faire un GET à la racine / renvoie sur
* /login ou sur /admin selon que l'utilisateur est connecté ou non.
*/
router
.
get
(
'
/
'
,
function
(
req
,
res
)
{
console
.
log
(
'
Redirecting to admin page...
'
);
res
.
redirect
(
'
/admin
'
);
});
router
.
get
(
'
/login
'
,
function
(
req
,
res
)
{
console
.
log
(
'
Connecting to
'
+
req
.
url
);
req
.
flash
(
'
failureFlash
'
,
'
Invalid username or password.
'
);
res
.
render
(
'
login
'
,
{
title
:
'
Login
'
,
port
:
port
,
errorMessage
:
req
.
flash
(
'
error
'
)
});
});
/**
* @description Le login se fait en POST. Faire un GET à /login renvoie à la racine /
*/
router
.
get
(
'
/login
'
,
function
(
req
,
res
)
{
console
.
log
(
'
Redirecting to home...
'
);
res
.
redirect
(
'
/
'
);
});
router
.
get
(
'
/admin
'
,
ensureLoggedIn
(
'
/login
'
),
function
(
req
,
res
)
{
...
...
@@ -52,8 +54,9 @@ router.get('/admin',
router
.
post
(
'
/login
'
,
passport
.
authenticate
(
'
ldapauth
'
,
{
successRedirect
:
'
/admin
'
,
failureRedirect
:
'
/
'
,
failureRedirect
:
'
/
login
'
,
failureFlash
:
true
}
// on a besoin de faire un callback apres le passport.authenticate car
// on souhaite garde l'information user.dn et body.password qq part.
// TODO: essayer de garder ces informations plus proprement...
...
...
@@ -70,7 +73,8 @@ router.post('/login',
}
}
*/
}));
)
);
router
.
post
(
'
/logout
'
,
function
(
req
,
res
)
{
req
.
logout
();
...
...
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