Do not allow invite email for login if cloudron mail is enabled

This commit is contained in:
Johannes Zellner
2016-09-27 17:12:37 +02:00
parent 34f624abef
commit a6547676a1
+5 -14
View File
@@ -266,26 +266,17 @@ function verifyWithEmail(email, password, callback) {
email = email.toLowerCase();
function checkWithEmailFromDatabase() {
settings.getMailConfig(function (error, mailConfig) {
if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error));
if (mailConfig.enabled) return verifyWithUsername(email.split('@')[0], password, callback);
userdb.getByEmail(email, function (error, user) {
if (error && error.reason == DatabaseError.NOT_FOUND) return callback(new UserError(UserError.NOT_FOUND));
if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error));
verify(user.id, password, callback);
});
}
settings.getMailConfig(function (error, mailConfig) {
if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error));
if (!mailConfig.enabled) return checkWithEmailFromDatabase();
verifyWithUsername(email.split('@')[0], password, function (error, result) {
if (!error) return callback(null, result);
if (error.reason !== UserError.NOT_FOUND) return callback(error);
checkWithEmailFromDatabase();
});
});
}