Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
m4lab_tv1
User Account
Commits
69511069
Commit
69511069
authored
5 years ago
by
Wolfgang Knopki
Browse files
Options
Download
Email Patches
Plain Diff
set paths to relative instead of global
parent
965a24d9
master
MLAB-677
devel
devel_wolfgang
patch-1
reset-jul13
reset-merge
test_logoutbutton
testing
Pipeline
#343
passed with stage
in 8 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
routes/routes.js
+32
-32
routes/routes.js
with
32 additions
and
32 deletions
+32
-32
routes/routes.js
+
32
-
32
View file @
69511069
...
@@ -63,40 +63,40 @@ module.exports = function (app, config, passport) {
...
@@ -63,40 +63,40 @@ module.exports = function (app, config, passport) {
res.send(JSON.stringify(req.flash('test')));
res.send(JSON.stringify(req.flash('test')));
});
});
*/
*/
app
.
get
(
'
/
'
,
function
(
req
,
res
)
{
app
.
get
(
'
.
/
'
,
function
(
req
,
res
)
{
res
.
redirect
(
'
/profile
'
)
res
.
redirect
(
'
.
/profile
'
)
});
});
app
.
get
(
'
/login
'
,
app
.
get
(
'
.
/login
'
,
passport
.
authenticate
(
config
.
passport
.
strategy
,
passport
.
authenticate
(
config
.
passport
.
strategy
,
{
{
successRedirect
:
'
/
'
,
successRedirect
:
'
.
/
'
,
failureRedirect
:
'
/login
'
failureRedirect
:
'
.
/login
'
})
})
);
);
app
.
post
(
config
.
passport
.
saml
.
path
,
app
.
post
(
config
.
passport
.
saml
.
path
,
passport
.
authenticate
(
config
.
passport
.
strategy
,
passport
.
authenticate
(
config
.
passport
.
strategy
,
{
{
failureRedirect
:
'
/
'
,
failureRedirect
:
'
.
/
'
,
failureFlash
:
true
failureFlash
:
true
}),
}),
function
(
req
,
res
)
{
function
(
req
,
res
)
{
res
.
redirect
(
'
/
'
);
res
.
redirect
(
'
.
/
'
);
}
}
);
);
app
.
get
(
'
/profile
'
,
function
(
req
,
res
)
{
app
.
get
(
'
.
/profile
'
,
function
(
req
,
res
)
{
if
(
req
.
isAuthenticated
())
{
if
(
req
.
isAuthenticated
())
{
res
.
render
(
'
profile
'
,
{
res
.
render
(
'
profile
'
,
{
user
:
req
.
user
// useful for view engine, useless for HTML
user
:
req
.
user
// useful for view engine, useless for HTML
});
});
}
else
{
}
else
{
res
.
redirect
(
'
/login
'
);
res
.
redirect
(
'
.
/login
'
);
}
}
});
});
app
.
get
(
'
/services
'
,
function
(
req
,
res
)
{
app
.
get
(
'
.
/services
'
,
function
(
req
,
res
)
{
if
(
req
.
isAuthenticated
())
{
if
(
req
.
isAuthenticated
())
{
async
.
waterfall
([
async
.
waterfall
([
// get userId by email from userdb
// get userId by email from userdb
...
@@ -156,21 +156,21 @@ module.exports = function (app, config, passport) {
...
@@ -156,21 +156,21 @@ module.exports = function (app, config, passport) {
}
}
])
])
}
else
{
}
else
{
res
.
redirect
(
'
/login
'
);
res
.
redirect
(
'
.
/login
'
);
}
}
});
});
app
.
get
(
'
/security
'
,
function
(
req
,
res
)
{
app
.
get
(
'
.
/security
'
,
function
(
req
,
res
)
{
if
(
req
.
isAuthenticated
())
{
if
(
req
.
isAuthenticated
())
{
res
.
render
(
'
security
'
,
{
res
.
render
(
'
security
'
,
{
user
:
req
.
user
// useful for view engine, useless for HTML
user
:
req
.
user
// useful for view engine, useless for HTML
});
});
}
else
{
}
else
{
res
.
redirect
(
'
/login
'
);
res
.
redirect
(
'
.
/login
'
);
}
}
});
});
app
.
post
(
'
/updateProfile
'
,
function
(
req
,
res
)
{
app
.
post
(
'
.
/updateProfile
'
,
function
(
req
,
res
)
{
var
userData
=
{
var
userData
=
{
title
:
req
.
body
.
inputTitle
,
title
:
req
.
body
.
inputTitle
,
firstname
:
req
.
body
.
inputFirstname
,
firstname
:
req
.
body
.
inputFirstname
,
...
@@ -195,13 +195,13 @@ module.exports = function (app, config, passport) {
...
@@ -195,13 +195,13 @@ module.exports = function (app, config, passport) {
})
})
}
}
}
else
{
}
else
{
res
.
redirect
(
'
/login
'
);
res
.
redirect
(
'
.
/login
'
);
}
}
});
});
// todo: user registration with captcha
// todo: user registration with captcha
app
.
post
(
'
/changePwd
'
,
function
(
req
,
res
)
{
app
.
post
(
'
.
/changePwd
'
,
function
(
req
,
res
)
{
if
(
req
.
isAuthenticated
())
{
if
(
req
.
isAuthenticated
())
{
var
currPwd
=
req
.
body
.
inputCurrPwd
var
currPwd
=
req
.
body
.
inputCurrPwd
var
newPwd
=
req
.
body
.
inputNewPwd
var
newPwd
=
req
.
body
.
inputNewPwd
...
@@ -210,7 +210,7 @@ module.exports = function (app, config, passport) {
...
@@ -210,7 +210,7 @@ module.exports = function (app, config, passport) {
// Load hashed passwd from DB.
// Load hashed passwd from DB.
dbconn
.
user
.
query
(
'
SELECT password FROM user WHERE email="
'
+
req
.
user
.
email
+
'
"
'
,
function
(
err
,
rows
,
fields
)
{
dbconn
.
user
.
query
(
'
SELECT password FROM user WHERE email="
'
+
req
.
user
.
email
+
'
"
'
,
function
(
err
,
rows
,
fields
)
{
if
(
err
)
{
if
(
err
)
{
res
.
redirect
(
'
/500
'
)
res
.
redirect
(
'
.
/500
'
)
throw
err
throw
err
}
}
var
userPwd
=
rows
[
0
].
password
var
userPwd
=
rows
[
0
].
password
...
@@ -218,16 +218,16 @@ module.exports = function (app, config, passport) {
...
@@ -218,16 +218,16 @@ module.exports = function (app, config, passport) {
// check if the password is correct
// check if the password is correct
bcrypt
.
compare
(
currPwd
,
userPwd
,
function
(
err
,
isMatch
)
{
bcrypt
.
compare
(
currPwd
,
userPwd
,
function
(
err
,
isMatch
)
{
if
(
err
)
{
if
(
err
)
{
res
.
redirect
(
'
/500
'
)
res
.
redirect
(
'
.
/500
'
)
throw
err
throw
err
}
}
else
if
(
!
isMatch
)
{
else
if
(
!
isMatch
)
{
req
.
flash
(
'
error
'
,
"
Sorry, your password was incorrect. Please double-check your password.
"
)
req
.
flash
(
'
error
'
,
"
Sorry, your password was incorrect. Please double-check your password.
"
)
res
.
redirect
(
'
/security
'
)
res
.
redirect
(
'
.
/security
'
)
}
else
{
}
else
{
if
(
newPwd
!=
retypePwd
)
{
if
(
newPwd
!=
retypePwd
)
{
req
.
flash
(
'
error
'
,
"
Passwords do no match. Please make sure you re-type your new password correctly.
"
)
req
.
flash
(
'
error
'
,
"
Passwords do no match. Please make sure you re-type your new password correctly.
"
)
res
.
redirect
(
'
/security
'
)
res
.
redirect
(
'
.
/security
'
)
}
}
else
{
else
{
// update password
// update password
...
@@ -242,7 +242,7 @@ module.exports = function (app, config, passport) {
...
@@ -242,7 +242,7 @@ module.exports = function (app, config, passport) {
req
.
flash
(
'
success
'
,
"
Pasword updated!
"
)
req
.
flash
(
'
success
'
,
"
Pasword updated!
"
)
console
.
log
(
'
pasword updated!
'
)
console
.
log
(
'
pasword updated!
'
)
}
}
res
.
redirect
(
'
/security
'
)
res
.
redirect
(
'
.
/security
'
)
})
})
});
});
});
});
...
@@ -251,11 +251,11 @@ module.exports = function (app, config, passport) {
...
@@ -251,11 +251,11 @@ module.exports = function (app, config, passport) {
})
})
})
})
}
else
{
}
else
{
res
.
redirect
(
'
/login
'
);
res
.
redirect
(
'
.
/login
'
);
}
}
});
});
app
.
get
(
'
/forgotPwd
'
,
function
(
req
,
res
)
{
app
.
get
(
'
.
/forgotPwd
'
,
function
(
req
,
res
)
{
res
.
render
(
'
forgotPwd
'
,
{
res
.
render
(
'
forgotPwd
'
,
{
user
:
req
.
user
user
:
req
.
user
});
});
...
@@ -284,7 +284,7 @@ module.exports = function (app, config, passport) {
...
@@ -284,7 +284,7 @@ module.exports = function (app, config, passport) {
text
:
""
text
:
""
};
};
app
.
post
(
'
/forgotPwd
'
,
function
(
req
,
res
,
next
)
{
app
.
post
(
'
.
/forgotPwd
'
,
function
(
req
,
res
,
next
)
{
//methods.currentDate();
//methods.currentDate();
/* do something: write down reset password procedure in Technical Req. Document
/* do something: write down reset password procedure in Technical Req. Document
ref: https://meanstackdeveloper.in/implement-reset-password-functionality-in-node-js-express.html
ref: https://meanstackdeveloper.in/implement-reset-password-functionality-in-node-js-express.html
...
@@ -345,16 +345,16 @@ module.exports = function (app, config, passport) {
...
@@ -345,16 +345,16 @@ module.exports = function (app, config, passport) {
else
{
else
{
req
.
flash
(
'
success
'
,
'
An e-mail has been sent to
'
+
emailAddress
+
'
with further instructions.
'
);
req
.
flash
(
'
success
'
,
'
An e-mail has been sent to
'
+
emailAddress
+
'
with further instructions.
'
);
}
}
res
.
redirect
(
'
/forgotPwd
'
);
res
.
redirect
(
'
.
/forgotPwd
'
);
});
});
});
});
app
.
get
(
'
/reset/:token
'
,
function
(
req
,
res
)
{
app
.
get
(
'
.
/reset/:token
'
,
function
(
req
,
res
)
{
methods
.
checkUserToken
(
req
.
params
.
token
,
function
(
err
,
user
){
methods
.
checkUserToken
(
req
.
params
.
token
,
function
(
err
,
user
){
//console.log(user);
//console.log(user);
if
(
!
user
)
{
if
(
!
user
)
{
req
.
flash
(
'
error
'
,
'
Password reset token is invalid or has expired.
'
);
req
.
flash
(
'
error
'
,
'
Password reset token is invalid or has expired.
'
);
res
.
redirect
(
'
/forgotPwd
'
);
res
.
redirect
(
'
.
/forgotPwd
'
);
}
}
else
{
else
{
res
.
render
(
'
reset
'
);
res
.
render
(
'
reset
'
);
...
@@ -362,7 +362,7 @@ module.exports = function (app, config, passport) {
...
@@ -362,7 +362,7 @@ module.exports = function (app, config, passport) {
});
});
});
});
app
.
post
(
'
/reset/:token
'
,
function
(
req
,
res
)
{
app
.
post
(
'
.
/reset/:token
'
,
function
(
req
,
res
)
{
methods
.
checkUserToken
(
req
.
params
.
token
,
function
(
err
,
user
){
methods
.
checkUserToken
(
req
.
params
.
token
,
function
(
err
,
user
){
if
(
user
)
{
if
(
user
)
{
// update password
// update password
...
@@ -387,12 +387,12 @@ module.exports = function (app, config, passport) {
...
@@ -387,12 +387,12 @@ module.exports = function (app, config, passport) {
}
}
});
});
res
.
redirect
(
'
/login
'
)
res
.
redirect
(
'
.
/login
'
)
});
});
app
.
get
(
'
/logout
'
,
function
(
req
,
res
)
{
app
.
get
(
'
.
/logout
'
,
function
(
req
,
res
)
{
if
(
req
.
user
==
null
)
{
if
(
req
.
user
==
null
)
{
return
res
.
redirect
(
'
/
'
);
return
res
.
redirect
(
'
.
/
'
);
}
}
req
.
user
.
nameID
=
req
.
user
.
id
;
req
.
user
.
nameID
=
req
.
user
.
id
;
...
@@ -414,7 +414,7 @@ module.exports = function (app, config, passport) {
...
@@ -414,7 +414,7 @@ module.exports = function (app, config, passport) {
});
});
// to generate Service Provider's XML metadata
// to generate Service Provider's XML metadata
app
.
get
(
'
/saml/metadata
'
,
app
.
get
(
'
.
/saml/metadata
'
,
function
(
req
,
res
)
{
function
(
req
,
res
)
{
res
.
type
(
'
application/xml
'
);
res
.
type
(
'
application/xml
'
);
var
spMetadata
=
samlStrategy
.
generateServiceProviderMetadata
(
fs
.
readFileSync
(
__dirname
+
'
/cert/cert.pem
'
,
'
utf8
'
));
var
spMetadata
=
samlStrategy
.
generateServiceProviderMetadata
(
fs
.
readFileSync
(
__dirname
+
'
/cert/cert.pem
'
,
'
utf8
'
));
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets