mirror of
https://github.com/wassname/talk.git
synced 2026-09-10 12:43:11 +08:00
Removed 3.4 dep
This commit is contained in:
+9
-7
@@ -10,13 +10,15 @@ machine:
|
||||
|
||||
dependencies:
|
||||
override:
|
||||
# Upgrade the database version to 3.4.
|
||||
- sudo apt-get purge mongodb-org*
|
||||
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
|
||||
- echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install -y mongodb-org
|
||||
- sudo service mongod restart
|
||||
# TODO: use the following to add in support for MongoDB 3.4.
|
||||
# # Upgrade the database version to 3.4.
|
||||
# - sudo apt-get purge mongodb-org*
|
||||
# - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
|
||||
# - echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
|
||||
# - sudo apt-get update
|
||||
# - sudo apt-get install -y mongodb-org
|
||||
# - sudo service mongod restart
|
||||
|
||||
# Install node dependencies.
|
||||
- yarn
|
||||
cache_directories:
|
||||
|
||||
+9
-10
@@ -66,6 +66,15 @@ const UserSchema = new mongoose.Schema({
|
||||
required: true
|
||||
},
|
||||
|
||||
// TODO: find a way that we can instead utilize MongoDB 3.4's collation
|
||||
// options to build the index in a case insenstive manner:
|
||||
// https://docs.mongodb.com/manual/reference/collation/
|
||||
lowercaseUsername: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true
|
||||
},
|
||||
|
||||
// This is true when the user account is disabled, no action should be
|
||||
// acknowledged when they are disabled. Logins are also prevented.
|
||||
disabled: Boolean,
|
||||
@@ -126,16 +135,6 @@ UserSchema.index({
|
||||
background: false
|
||||
});
|
||||
|
||||
UserSchema.index({
|
||||
'username': 1
|
||||
}, {
|
||||
unique: true,
|
||||
collation: {
|
||||
locale: 'en_US',
|
||||
strength: 2
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns true if the user has all the roles specified.
|
||||
*/
|
||||
|
||||
+12
-4
@@ -99,6 +99,10 @@ module.exports = class UsersService {
|
||||
.then(() => dstUser.save());
|
||||
}
|
||||
|
||||
static castDisplayName(displayName) {
|
||||
return displayName.replace(/ /g, '_').replace(/[^a-zA-Z_]/g, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a user given a social profile and if the user does not exist, creates
|
||||
* them.
|
||||
@@ -120,12 +124,14 @@ module.exports = class UsersService {
|
||||
return user;
|
||||
}
|
||||
|
||||
// TODO: remove displayName reference when we have steps in the FE to handle
|
||||
// the username create flow.
|
||||
let username = UsersService.castDisplayName(displayName);
|
||||
|
||||
// The user was not found, lets create them!
|
||||
user = new UserModel({
|
||||
|
||||
// TODO: remove displayName reference when we have steps in the FE to handle
|
||||
// the username create flow.
|
||||
username: displayName.replace(/ /g, '_').replace(/[^a-zA-Z_]/g, ''),
|
||||
username,
|
||||
lowercaseUsername: username.toLowerCase(),
|
||||
roles: [],
|
||||
profiles: [{id, provider}]
|
||||
});
|
||||
@@ -238,6 +244,7 @@ module.exports = class UsersService {
|
||||
|
||||
let user = new UserModel({
|
||||
username,
|
||||
lowercaseUsername: username.toLowerCase(),
|
||||
password: hashedPassword,
|
||||
roles: [],
|
||||
profiles: [
|
||||
@@ -677,6 +684,7 @@ module.exports = class UsersService {
|
||||
}, {
|
||||
$set: {
|
||||
username: username,
|
||||
lowercaseUsername: username.toLowerCase(),
|
||||
canEditName: false,
|
||||
status: 'PENDING'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user