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
339ce36f
Commit
339ce36f
authored
Feb 14, 2020
by
Wolfgang Knopki
Browse files
updated URLs to match deployment
parent
04eb2f97
Changes
2
Hide whitespace changes
Inline
Side-by-side
config/config.js
View file @
339ce36f
...
@@ -14,7 +14,7 @@ module.exports = {
...
@@ -14,7 +14,7 @@ module.exports = {
}
}
},
},
database
:
{
database
:
{
host
:
'
localhost
'
,
// DB host
host
:
'
tranmsfer.hft-stuttgart.de
'
,
// DB host
user
:
'
DBManager
'
,
// DB username
user
:
'
DBManager
'
,
// DB username
password
:
'
Stuttgart2019
'
,
// DB password
password
:
'
Stuttgart2019
'
,
// DB password
port
:
3306
,
// MySQL port
port
:
3306
,
// MySQL port
...
...
routes/routes.js
View file @
339ce36f
...
@@ -124,14 +124,14 @@ module.exports = function (app, config, passport) {
...
@@ -124,14 +124,14 @@ module.exports = function (app, config, passport) {
app
.
get
(
'
/login
'
,
app
.
get
(
'
/login
'
,
passport
.
authenticate
(
config
.
passport
.
strategy
,
passport
.
authenticate
(
config
.
passport
.
strategy
,
{
{
successRedirect
:
'
/
'
,
successRedirect
:
'
/
account/
'
,
failureRedirect
:
'
/login
'
failureRedirect
:
'
/
account/
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
(
'
/
account/
'
);
}
}
req
.
user
.
nameID
=
req
.
user
.
id
;
req
.
user
.
nameID
=
req
.
user
.
id
;
...
@@ -162,7 +162,7 @@ module.exports = function (app, config, passport) {
...
@@ -162,7 +162,7 @@ module.exports = function (app, config, passport) {
}
}
})
})
}
else
{
}
else
{
res
.
redirect
(
'
/login
'
);
res
.
redirect
(
'
/
account/
login
'
);
}
}
});
});
...
@@ -226,7 +226,7 @@ module.exports = function (app, config, passport) {
...
@@ -226,7 +226,7 @@ module.exports = function (app, config, passport) {
}
}
])
])
}
else
{
}
else
{
res
.
redirect
(
'
/login
'
);
res
.
redirect
(
'
/
account/
login
'
);
}
}
});
});
...
@@ -236,7 +236,7 @@ module.exports = function (app, config, passport) {
...
@@ -236,7 +236,7 @@ module.exports = function (app, config, passport) {
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
(
'
/
account/
login
'
);
}
}
});
});
...
@@ -261,11 +261,11 @@ module.exports = function (app, config, passport) {
...
@@ -261,11 +261,11 @@ module.exports = function (app, config, passport) {
else
{
else
{
req
.
flash
(
'
success
'
,
'
Profile updated!
'
);
req
.
flash
(
'
success
'
,
'
Profile updated!
'
);
}
}
res
.
redirect
(
'
/profile
'
);
res
.
redirect
(
'
/
account/
profile
'
);
})
})
}
}
}
else
{
}
else
{
res
.
redirect
(
'
/login
'
);
res
.
redirect
(
'
/
account/
login
'
);
}
}
});
});
...
@@ -280,7 +280,7 @@ module.exports = function (app, config, passport) {
...
@@ -280,7 +280,7 @@ module.exports = function (app, config, passport) {
// Load hashed passwd from DB
// Load hashed passwd from DB
dbconn
.
user
.
query
(
'
SELECT password FROM credential WHERE user_id=
'
+
userId
,
function
(
err
,
rows
,
fields
)
{
dbconn
.
user
.
query
(
'
SELECT password FROM credential WHERE user_id=
'
+
userId
,
function
(
err
,
rows
,
fields
)
{
if
(
err
)
{
if
(
err
)
{
res
.
redirect
(
'
/500
'
)
res
.
redirect
(
'
/
account/
500
'
)
throw
err
throw
err
}
}
var
userPwd
=
rows
[
0
].
password
var
userPwd
=
rows
[
0
].
password
...
@@ -288,17 +288,17 @@ module.exports = function (app, config, passport) {
...
@@ -288,17 +288,17 @@ 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
(
'
/
account/
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
(
'
/
account/
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
(
'
/
account/
security
'
)
}
}
else
{
else
{
// update password
// update password
...
@@ -324,7 +324,7 @@ module.exports = function (app, config, passport) {
...
@@ -324,7 +324,7 @@ module.exports = function (app, config, passport) {
}
}
});
});
}
}
res
.
redirect
(
'
/security
'
)
res
.
redirect
(
'
/
account/
security
'
)
})
})
});
});
});
});
...
@@ -336,7 +336,7 @@ module.exports = function (app, config, passport) {
...
@@ -336,7 +336,7 @@ module.exports = function (app, config, passport) {
})
})
}
}
else
{
else
{
res
.
redirect
(
'
/login
'
);
res
.
redirect
(
'
/
account/
login
'
);
}
}
});
});
...
@@ -369,7 +369,7 @@ module.exports = function (app, config, passport) {
...
@@ -369,7 +369,7 @@ module.exports = function (app, config, passport) {
emailSubject
=
"
M4_LAB Password Reset
"
;
emailSubject
=
"
M4_LAB Password Reset
"
;
emailContent
=
"
Hi User,
\n\n
"
+
emailContent
=
"
Hi User,
\n\n
"
+
"
we've received a request to reset your password. If you didn't make the request, just ignore this email.
\n\n
"
+
"
we've received a request to reset your password. If you didn't make the request, just ignore this email.
\n\n
"
+
"
Otherwise, you can reset your password using this link: http://
localhost:9989
/reset/
"
+
token
+
"
\n
"
+
"
Otherwise, you can reset your password using this link: http://
m4lab.hft-stuttgart.de/account
/reset/
"
+
token
+
"
\n
"
+
"
This password reset is only valid for 1 hour.
\n\n
"
+
"
This password reset is only valid for 1 hour.
\n\n
"
+
"
Thanks,
\n
M4_LAB Team
"
"
Thanks,
\n
M4_LAB Team
"
...
@@ -402,7 +402,7 @@ module.exports = function (app, config, passport) {
...
@@ -402,7 +402,7 @@ 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
(
'
/
account/
forgotPwd
'
);
});
});
});
});
...
@@ -410,7 +410,7 @@ module.exports = function (app, config, passport) {
...
@@ -410,7 +410,7 @@ module.exports = function (app, config, passport) {
methods
.
getUserByToken
(
req
.
params
.
token
,
function
(
err
,
user
){
methods
.
getUserByToken
(
req
.
params
.
token
,
function
(
err
,
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
(
'
/
account/
forgotPwd
'
);
}
}
else
{
else
{
res
.
render
(
'
reset
'
);
res
.
render
(
'
reset
'
);
...
@@ -447,7 +447,7 @@ module.exports = function (app, config, passport) {
...
@@ -447,7 +447,7 @@ module.exports = function (app, config, passport) {
}
}
});
});
// redirect to login page
// redirect to login page
res
.
redirect
(
'
/login
'
)
res
.
redirect
(
'
/
account/
login
'
)
}
}
})
})
});
});
...
@@ -455,7 +455,7 @@ module.exports = function (app, config, passport) {
...
@@ -455,7 +455,7 @@ module.exports = function (app, config, passport) {
}
}
else
{
else
{
req
.
flash
(
'
error
'
,
"
User not found.
"
)
req
.
flash
(
'
error
'
,
"
User not found.
"
)
res
.
redirect
(
'
/login
'
)
res
.
redirect
(
'
/
account/
login
'
)
}
}
});
});
...
@@ -498,7 +498,7 @@ module.exports = function (app, config, passport) {
...
@@ -498,7 +498,7 @@ module.exports = function (app, config, passport) {
else
{
else
{
req
.
flash
(
'
success
'
,
'
Your account has been created. Please log in.
'
);
req
.
flash
(
'
success
'
,
'
Your account has been created. Please log in.
'
);
}
}
res
.
redirect
(
'
/registration
'
);
res
.
redirect
(
'
/
account/
registration
'
);
})
})
});
});
});
});
...
...
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