fix: WebPush Notification

This commit is contained in:
Paolo Arena
2019-02-13 18:47:58 +01:00
parent df31a9ea9b
commit 0b4ac6391d
8 changed files with 115 additions and 88 deletions

View File

@@ -127,6 +127,22 @@ UserSchema.statics.findByToken = function (token, typeaccess) {
});
};
UserSchema.statics.findByTokenAnyAccess = function (token) {
var User = this;
var decoded;
try {
decoded = jwt.verify(token, process.env.SIGNCODE);
} catch (e) {
return Promise.resolve(null);
}
return User.findOne({
'_id': decoded._id,
'tokens.token': token,
});
};
UserSchema.statics.findByCredentials = function (username, password) {
var User = this;
var pwd = "";