mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 12:02:13 +00: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:
parent
a078889d58
commit
44d67ac9f8
1 changed files with 10 additions and 1 deletions
|
|
@ -265,7 +265,16 @@ UserSchema.virtual('tasks').get(function () {
|
|||
// Custom setter/getter virtuals?
|
||||
|
||||
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
|
||||
this._v++;
|
||||
next();
|
||||
|
|
|
|||
Loading…
Reference in a new issue