Do not allow invite email for login if cloudron mail is enabled
This commit is contained in:
+5
-14
@@ -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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user