mirror of
https://github.com/wassname/talk.git
synced 2026-07-27 11:28:12 +08:00
Merge pull request #323 from coralproject/more-lingering-displayname-bugs
Standardizing username
This commit is contained in:
+1
-1
@@ -120,7 +120,7 @@ const performSetup = () => {
|
||||
message: 'Username',
|
||||
filter: (username) => {
|
||||
return UsersService
|
||||
.isValidDisplayName(username, false)
|
||||
.isValidUsername(username, false)
|
||||
.catch((err) => {
|
||||
throw err.message;
|
||||
});
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ function getUserCreateAnswers(options) {
|
||||
message: 'Username',
|
||||
filter: (username) => {
|
||||
return UsersService
|
||||
.isValidDisplayName(username)
|
||||
.isValidUsername(username)
|
||||
.catch((err) => {
|
||||
throw err.message;
|
||||
});
|
||||
|
||||
@@ -103,9 +103,9 @@ if (process.env.TALK_FACEBOOK_APP_ID && process.env.TALK_FACEBOOK_APP_SECRET &&
|
||||
clientSecret: process.env.TALK_FACEBOOK_APP_SECRET,
|
||||
callbackURL: `${process.env.TALK_ROOT_URL}/api/v1/auth/facebook/callback`,
|
||||
|
||||
// TODO: remove displayName reference when we have steps in the FE to handle
|
||||
// TODO: remove username reference when we have steps in the FE to handle
|
||||
// the username create flow.
|
||||
profileFields: ['id', 'displayName', 'picture.type(large)']
|
||||
profileFields: ['id', 'username', 'picture.type(large)']
|
||||
}, (accessToken, refreshToken, profile, done) => {
|
||||
UsersService
|
||||
.findOrCreateExternalUser(profile)
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ module.exports = class SetupService {
|
||||
|
||||
// Verify other properties of the user.
|
||||
return Promise.all([
|
||||
UsersService.isValidDisplayName(username, false),
|
||||
UsersService.isValidUsername(username, false),
|
||||
UsersService.isValidPassword(password),
|
||||
settingsModel.validate()
|
||||
]);
|
||||
|
||||
+2
-2
@@ -176,7 +176,7 @@ module.exports = class UsersService {
|
||||
* @param {Boolean} checkAgainstWordlist enables cheching against the wordlist
|
||||
* @return {Promise}
|
||||
*/
|
||||
static isValidUserName(username, checkAgainstWordlist = true) {
|
||||
static isValidUsername(username, checkAgainstWordlist = true) {
|
||||
const onlyLettersNumbersUnderscore = /^[A-Za-z0-9_]+$/;
|
||||
|
||||
if (!username) {
|
||||
@@ -230,7 +230,7 @@ module.exports = class UsersService {
|
||||
username = username.trim();
|
||||
|
||||
return Promise.all([
|
||||
UsersService.isValidUserName(username),
|
||||
UsersService.isValidUsername(username),
|
||||
UsersService.isValidPassword(password)
|
||||
])
|
||||
.then(() => { // username is valid
|
||||
|
||||
Reference in New Issue
Block a user