mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-12 16:57:39 -05:00
Terms of Service added
This commit is contained in:
@@ -28,18 +28,23 @@ const local = new LocalStrategy({
|
||||
});
|
||||
if (!user) {
|
||||
console.error("Auth Error - user not found: " + email);
|
||||
return done(null, false, { message: `Invalid email or password` })
|
||||
return done(null, false, { message: `Invalid email or password`, reason: "invalid" })
|
||||
}
|
||||
if (!user.confirmEmail) {
|
||||
console.error("Auth Error - user has not confirmed email: " + email);
|
||||
return done(null, false, { message: `User's email is not confirmed` })
|
||||
return done(null, false, { message: `User's email is not confirmed`, reason: "unconfirmed email"})
|
||||
}
|
||||
/*
|
||||
if (user.terms != 1.1) {
|
||||
console.error("Auth Error - user has not accepted TOS: " + email);
|
||||
return done(null, false, { message: `User has not accepted the Terms of Service`, reason: "unaccepted TOS"})
|
||||
}*/
|
||||
user.comparePassword(password, (err, isMatch) => {
|
||||
if (isMatch) {
|
||||
return done(null, user)
|
||||
} else {
|
||||
console.error("Auth Error - password mismatch: " + email);
|
||||
return done(null, false, { message: "Invalid email or password" })
|
||||
return done(null, false, { message: "Invalid email or password", reason: "invalid"})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -37,14 +37,16 @@ exports.authenticated = function (req, res, next) {
|
||||
screenName,
|
||||
location,
|
||||
email,
|
||||
admin
|
||||
admin,
|
||||
terms
|
||||
}) => ({
|
||||
firstName,
|
||||
lastName,
|
||||
screenName,
|
||||
location,
|
||||
email,
|
||||
admin
|
||||
admin,
|
||||
terms
|
||||
}))(
|
||||
req.user
|
||||
);
|
||||
@@ -71,7 +73,8 @@ exports.login = function (req, res, next) {
|
||||
console.log("No user");
|
||||
return res.json({
|
||||
success: false,
|
||||
message: info.message
|
||||
message: info.message,
|
||||
reason: info.reason
|
||||
});
|
||||
}
|
||||
// ***********************************************************************
|
||||
@@ -99,6 +102,7 @@ exports.login = function (req, res, next) {
|
||||
return res.json({
|
||||
success: false,
|
||||
message: "unconfirmed email",
|
||||
reason: "unconfirmed email",
|
||||
userId: user.id
|
||||
});
|
||||
});
|
||||
@@ -111,14 +115,16 @@ exports.login = function (req, res, next) {
|
||||
screenName,
|
||||
location,
|
||||
email,
|
||||
admin
|
||||
admin,
|
||||
terms
|
||||
}) => ({
|
||||
firstName,
|
||||
lastName,
|
||||
screenName,
|
||||
location,
|
||||
email,
|
||||
admin
|
||||
admin,
|
||||
terms
|
||||
}))(
|
||||
user
|
||||
);
|
||||
@@ -480,8 +486,16 @@ exports.terms = async function (req, res, next) {
|
||||
});
|
||||
return;
|
||||
});
|
||||
var clientUser = (({
|
||||
terms
|
||||
}) => ({
|
||||
terms
|
||||
}))(
|
||||
user
|
||||
);
|
||||
res.json({
|
||||
success: true
|
||||
success: true,
|
||||
user: clientUser
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user