Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
m4lab_tv1
User Account
Commits
f6b48076
Commit
f6b48076
authored
Dec 11, 2019
by
Wolfgang Knopki
Browse files
merging new features
parents
0b885ec3
e32c0fcc
Pipeline
#370
passed with stage
in 9 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
routes/routes.js
View file @
f6b48076
...
@@ -54,15 +54,37 @@ module.exports = function (app, config, passport) {
...
@@ -54,15 +54,37 @@ module.exports = function (app, config, passport) {
passport
.
use
(
samlStrategy
);
passport
.
use
(
samlStrategy
);
// ============================
/*
app.all('/', function(req, res){
req.flash('test', 'it worked');
res.redirect('/test')
});
app.all('/test', function(req, res){
res.send(JSON.stringify(req.flash('test')));
});
*/
app
.
get
(
'
/
'
,
function
(
req
,
res
)
{
res
.
redirect
(
'
/account/profile
'
)
});
app
.
get
(
'
/login
'
,
passport
.
authenticate
(
config
.
passport
.
strategy
,
{
successRedirect
:
'
/account/
'
,
failureRedirect
:
'
/account/login
'
})
);
// ============= SAML ==============
// ============= SAML ==============
app
.
post
(
config
.
passport
.
saml
.
path
,
app
.
post
(
config
.
passport
.
saml
.
path
,
passport
.
authenticate
(
config
.
passport
.
strategy
,
passport
.
authenticate
(
config
.
passport
.
strategy
,
{
{
failureRedirect
:
'
/
'
,
failureRedirect
:
'
/
account/
'
,
failureFlash
:
true
failureFlash
:
true
}),
}),
function
(
req
,
res
)
{
function
(
req
,
res
)
{
res
.
redirect
(
'
/
'
);
res
.
redirect
(
'
/
account/
'
);
}
}
);
);
...
@@ -399,7 +421,7 @@ module.exports = function (app, config, passport) {
...
@@ -399,7 +421,7 @@ module.exports = function (app, config, passport) {
if
(
user
)
{
if
(
user
)
{
// encrypt password
// encrypt password
bcrypt
.
genSalt
(
saltRounds
,
function
(
err
,
salt
)
{
bcrypt
.
genSalt
(
saltRounds
,
function
(
err
,
salt
)
{
bcrypt
.
hash
(
req
.
body
.
inputN
ewPwd
,
salt
,
function
(
err
,
hash
)
{
bcrypt
.
hash
(
n
ewPwd
,
salt
,
function
(
err
,
hash
)
{
var
credentialData
=
{
var
credentialData
=
{
password
:
hash
,
password
:
hash
,
user_id
:
user
.
user_id
user_id
:
user
.
user_id
...
@@ -427,27 +449,9 @@ module.exports = function (app, config, passport) {
...
@@ -427,27 +449,9 @@ module.exports = function (app, config, passport) {
res
.
redirect
(
'
/account/login
'
)
res
.
redirect
(
'
/account/login
'
)
});
});
// todo: user registration with captcha
app
.
get
(
'
/logout
'
,
function
(
req
,
res
)
{
app
.
get
(
'
/registration
'
,
function
(
req
,
res
)
{
if
(
req
.
user
==
null
)
{
res
.
render
(
'
registration
'
)
return
res
.
redirect
(
'
/account/
'
);
})
app
.
post
(
'
/registration
'
,
function
(
req
,
res
)
{
// TODO:
// create gitlab account?
// send email to activate profile?
// user data
var
curDate
=
new
Date
()
var
userData
=
{
title
:
req
.
body
.
inputTitle
,
firstname
:
req
.
body
.
inputFirstname
,
lastname
:
req
.
body
.
inputLastname
,
email
:
req
.
body
.
inputEmail
,
organisation
:
req
.
body
.
inputOrganisation
,
industry
:
req
.
body
.
inputIndustry
,
speciality
:
req
.
body
.
inputSpeciality
,
createdDate
:
curDate
.
toISOString
().
slice
(
0
,
10
)
}
}
// encrypt password
// encrypt password
bcrypt
.
genSalt
(
saltRounds
,
function
(
err
,
salt
)
{
bcrypt
.
genSalt
(
saltRounds
,
function
(
err
,
salt
)
{
...
...
views/profile.pug
View file @
f6b48076
...
@@ -87,5 +87,4 @@ html(lang="en")
...
@@ -87,5 +87,4 @@ html(lang="en")
// Bootstrap
// Bootstrap
script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous")
script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous")
// M4_LAB
// M4_LAB
script(src="/account/js/account.js")
script(src="/js/headfoot.js")
script(src="/js/headfoot.js")
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