Removed 3.4 dep

This commit is contained in:
Wyatt Johnson
2017-02-13 10:49:47 -07:00
parent 4e73d7fc23
commit b30a5d2184
3 changed files with 30 additions and 21 deletions
+9 -7
View File
@@ -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
View File
@@ -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
View File
@@ -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'
}