Do some cleanups on the data
This commit is contained in:
parent
8cb48abb39
commit
0d792817fe
@ -62,6 +62,17 @@ const API = {
|
||||
uuid: uuidV1()
|
||||
}, data)
|
||||
|
||||
// Some data cleanups
|
||||
|
||||
// Limit display name length
|
||||
udataLimited.display_name = udataLimited.display_name.substring(0, 32)
|
||||
|
||||
// Remove illegal characters from the username
|
||||
udataLimited.username = udataLimited.username.replace(/\W+/gi, '')
|
||||
|
||||
// Limit user name length
|
||||
udataLimited.username = udataLimited.username.substring(0, 26)
|
||||
|
||||
// Check if the username is already taken
|
||||
if (await UAPI.User.get(udataLimited.username) != null) {
|
||||
udataLimited.username = udataLimited.username + UAPI.Hash(4)
|
||||
@ -77,7 +88,7 @@ const API = {
|
||||
}
|
||||
}
|
||||
|
||||
// Create a new user based on the information we got from Facebook
|
||||
// Create a new user based on the information we got from an external service
|
||||
let newUser = await models.User.query().insert(udataLimited)
|
||||
await API.Common.new(service, identifier, newUser)
|
||||
|
||||
@ -317,7 +328,7 @@ const API = {
|
||||
}
|
||||
|
||||
let cleanedData = Object.assign(data, {
|
||||
username: data.name.replace(/\W+/gi, ''),
|
||||
username: data.name,
|
||||
display_name: data.name,
|
||||
email: data.email || ''
|
||||
})
|
||||
@ -404,7 +415,6 @@ const API = {
|
||||
|
||||
// Create a new user
|
||||
let cleanedData = Object.assign(ddata, {
|
||||
username: ddata.username.replace(/\W+/gi, '_'),
|
||||
display_name: ddata.username,
|
||||
email: ddata.email || ''
|
||||
})
|
||||
|
Reference in New Issue
Block a user