mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
UserSchema: set default profile.name (either from facebook or username)
if not provided. This way we can remove the expensive username() helper function throughout our html
This commit is contained in:
@@ -265,7 +265,16 @@ UserSchema.virtual('tasks').get(function () {
|
|||||||
// Custom setter/getter virtuals?
|
// Custom setter/getter virtuals?
|
||||||
|
|
||||||
UserSchema.pre('save', function(next) {
|
UserSchema.pre('save', function(next) {
|
||||||
//this.markModified('tasks'); //FIXME
|
//this.markModified('tasks');
|
||||||
|
|
||||||
|
if (!this.profile.name) {
|
||||||
|
var fb = this.auth.facebook;
|
||||||
|
this.profile.name =
|
||||||
|
(this.auth.local && this.auth.local.username) ||
|
||||||
|
(fb && (fb.displayName || fb.name || fb.username || (fb.first_name && fb.first_name + ' ' + fb.last_name))) ||
|
||||||
|
'Anonymous';
|
||||||
|
}
|
||||||
|
|
||||||
//our own version incrementer
|
//our own version incrementer
|
||||||
this._v++;
|
this._v++;
|
||||||
next();
|
next();
|
||||||
|
|||||||
Reference in New Issue
Block a user