parse 5.1.1-alpha.1 → 5.2.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/parse.js +10186 -14918
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +10180 -15057
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Analytics.js +7 -11
- package/lib/browser/AnonymousUtils.js +17 -22
- package/lib/browser/Cloud.js +24 -46
- package/lib/browser/CoreManager.js +71 -79
- package/lib/browser/CryptoController.js +14 -9
- package/lib/browser/EventEmitter.js +9 -2
- package/lib/browser/EventuallyQueue.js +156 -357
- package/lib/browser/FacebookUtils.js +23 -28
- package/lib/browser/IndexedDBStorageController.js +18 -14
- package/lib/browser/InstallationController.js +55 -121
- package/lib/browser/LiveQueryClient.js +312 -446
- package/lib/browser/LiveQuerySubscription.js +25 -28
- package/lib/browser/LocalDatastore.js +254 -578
- package/lib/browser/LocalDatastoreController.default.js +48 -227
- package/lib/browser/LocalDatastoreController.js +11 -1
- package/lib/browser/LocalDatastoreController.react-native.js +72 -164
- package/lib/browser/LocalDatastoreUtils.js +4 -12
- package/lib/browser/ObjectStateMutations.js +89 -95
- package/lib/browser/OfflineQuery.js +106 -198
- package/lib/browser/Parse.js +45 -61
- package/lib/browser/ParseACL.js +242 -288
- package/lib/browser/ParseCLP.js +372 -580
- package/lib/browser/ParseConfig.js +115 -138
- package/lib/browser/ParseError.js +85 -182
- package/lib/browser/ParseFile.js +296 -444
- package/lib/browser/ParseGeoPoint.js +121 -140
- package/lib/browser/ParseHooks.js +12 -14
- package/lib/browser/ParseInstallation.js +226 -354
- package/lib/browser/ParseLiveQuery.js +74 -148
- package/lib/browser/ParseObject.js +2017 -2622
- package/lib/browser/ParseOp.js +343 -484
- package/lib/browser/ParsePolygon.js +101 -120
- package/lib/browser/ParseQuery.js +1722 -2068
- package/lib/browser/ParseRelation.js +99 -118
- package/lib/browser/ParseRole.js +88 -144
- package/lib/browser/ParseSchema.js +372 -434
- package/lib/browser/ParseSession.js +62 -110
- package/lib/browser/ParseUser.js +942 -1270
- package/lib/browser/Push.js +16 -44
- package/lib/browser/RESTController.js +85 -124
- package/lib/browser/SingleInstanceStateController.js +57 -86
- package/lib/browser/Socket.weapp.js +50 -33
- package/lib/browser/Storage.js +23 -28
- package/lib/browser/StorageController.browser.js +16 -13
- package/lib/browser/StorageController.default.js +15 -14
- package/lib/browser/StorageController.js +14 -1
- package/lib/browser/StorageController.react-native.js +31 -30
- package/lib/browser/StorageController.weapp.js +19 -13
- package/lib/browser/TaskQueue.js +37 -49
- package/lib/browser/UniqueInstanceStateController.js +65 -86
- package/lib/browser/WebSocketController.js +11 -4
- package/lib/browser/Xhr.weapp.js +90 -78
- package/lib/browser/arrayContainsObject.js +3 -3
- package/lib/browser/canBeSerialized.js +10 -11
- package/lib/browser/decode.js +11 -11
- package/lib/browser/encode.js +11 -11
- package/lib/browser/equals.js +9 -10
- package/lib/browser/escape.js +2 -2
- package/lib/browser/isRevocableSession.js +1 -1
- package/lib/browser/parseDate.js +10 -10
- package/lib/browser/promiseUtils.js +19 -19
- package/lib/browser/unique.js +4 -4
- package/lib/browser/unsavedChildren.js +20 -21
- package/lib/browser/uuid.js +2 -4
- package/lib/node/Analytics.js +2 -6
- package/lib/node/AnonymousUtils.js +7 -12
- package/lib/node/Cloud.js +8 -12
- package/lib/node/CoreManager.js +59 -67
- package/lib/node/CryptoController.js +8 -3
- package/lib/node/EventEmitter.js +7 -1
- package/lib/node/EventuallyQueue.js +18 -37
- package/lib/node/FacebookUtils.js +1 -5
- package/lib/node/IndexedDBStorageController.js +14 -10
- package/lib/node/InstallationController.js +7 -8
- package/lib/node/LiveQueryClient.js +20 -32
- package/lib/node/LiveQuerySubscription.js +3 -4
- package/lib/node/LocalDatastore.js +20 -24
- package/lib/node/LocalDatastoreController.default.js +12 -11
- package/lib/node/LocalDatastoreController.js +14 -1
- package/lib/node/LocalDatastoreController.react-native.js +27 -22
- package/lib/node/LocalDatastoreUtils.js +4 -12
- package/lib/node/ObjectStateMutations.js +52 -36
- package/lib/node/OfflineQuery.js +37 -23
- package/lib/node/Parse.js +35 -49
- package/lib/node/ParseACL.js +18 -27
- package/lib/node/ParseCLP.js +38 -50
- package/lib/node/ParseConfig.js +7 -14
- package/lib/node/ParseError.js +457 -458
- package/lib/node/ParseFile.js +33 -66
- package/lib/node/ParseGeoPoint.js +22 -17
- package/lib/node/ParseHooks.js +0 -2
- package/lib/node/ParseInstallation.js +21 -8
- package/lib/node/ParseLiveQuery.js +6 -11
- package/lib/node/ParseObject.js +138 -167
- package/lib/node/ParseOp.js +32 -44
- package/lib/node/ParsePolygon.js +11 -17
- package/lib/node/ParseQuery.js +118 -164
- package/lib/node/ParseRelation.js +7 -16
- package/lib/node/ParseRole.js +7 -13
- package/lib/node/ParseSchema.js +26 -39
- package/lib/node/ParseSession.js +7 -8
- package/lib/node/ParseUser.js +70 -76
- package/lib/node/Push.js +5 -15
- package/lib/node/RESTController.js +21 -33
- package/lib/node/SingleInstanceStateController.js +41 -69
- package/lib/node/Socket.weapp.js +23 -2
- package/lib/node/Storage.js +11 -16
- package/lib/node/StorageController.browser.js +10 -8
- package/lib/node/StorageController.default.js +9 -9
- package/lib/node/StorageController.js +16 -1
- package/lib/node/StorageController.react-native.js +17 -17
- package/lib/node/StorageController.weapp.js +14 -8
- package/lib/node/TaskQueue.js +8 -11
- package/lib/node/UniqueInstanceStateController.js +40 -60
- package/lib/node/WebSocketController.js +15 -2
- package/lib/node/Xhr.weapp.js +11 -2
- package/lib/node/arrayContainsObject.js +1 -1
- package/lib/node/canBeSerialized.js +2 -2
- package/lib/node/decode.js +1 -1
- package/lib/node/encode.js +2 -2
- package/lib/node/equals.js +1 -1
- package/lib/node/escape.js +1 -1
- package/lib/node/isRevocableSession.js +1 -1
- package/lib/node/parseDate.js +1 -1
- package/lib/node/promiseUtils.js +7 -7
- package/lib/node/unique.js +2 -2
- package/lib/node/unsavedChildren.js +2 -2
- package/lib/node/uuid.js +2 -4
- package/lib/react-native/Analytics.js +2 -2
- package/lib/react-native/AnonymousUtils.js +3 -4
- package/lib/react-native/Cloud.js +0 -1
- package/lib/react-native/CoreManager.js +2 -3
- package/lib/react-native/CryptoController.js +6 -1
- package/lib/react-native/EventEmitter.js +6 -1
- package/lib/react-native/EventuallyQueue.js +1 -2
- package/lib/react-native/FacebookUtils.js +1 -2
- package/lib/react-native/IndexedDBStorageController.js +11 -5
- package/lib/react-native/InstallationController.js +1 -2
- package/lib/react-native/LiveQueryClient.js +51 -36
- package/lib/react-native/LiveQuerySubscription.js +2 -4
- package/lib/react-native/LocalDatastore.js +41 -17
- package/lib/react-native/LocalDatastoreController.default.js +6 -1
- package/lib/react-native/LocalDatastoreController.js +11 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +16 -11
- package/lib/react-native/LocalDatastoreUtils.js +3 -6
- package/lib/react-native/ObjectStateMutations.js +30 -9
- package/lib/react-native/OfflineQuery.js +25 -20
- package/lib/react-native/Parse.js +24 -38
- package/lib/react-native/ParseACL.js +4 -6
- package/lib/react-native/ParseCLP.js +5 -7
- package/lib/react-native/ParseConfig.js +4 -6
- package/lib/react-native/ParseError.js +13 -31
- package/lib/react-native/ParseFile.js +10 -10
- package/lib/react-native/ParseGeoPoint.js +2 -4
- package/lib/react-native/ParseInstallation.js +13 -30
- package/lib/react-native/ParseLiveQuery.js +2 -4
- package/lib/react-native/ParseObject.js +81 -90
- package/lib/react-native/ParseOp.js +41 -79
- package/lib/react-native/ParsePolygon.js +2 -4
- package/lib/react-native/ParseQuery.js +87 -81
- package/lib/react-native/ParseRelation.js +2 -4
- package/lib/react-native/ParseRole.js +14 -31
- package/lib/react-native/ParseSchema.js +3 -5
- package/lib/react-native/ParseSession.js +12 -29
- package/lib/react-native/ParseUser.js +32 -51
- package/lib/react-native/RESTController.js +10 -4
- package/lib/react-native/SingleInstanceStateController.js +23 -37
- package/lib/react-native/Socket.weapp.js +9 -4
- package/lib/react-native/Storage.js +1 -2
- package/lib/react-native/StorageController.browser.js +6 -1
- package/lib/react-native/StorageController.default.js +6 -1
- package/lib/react-native/StorageController.js +13 -1
- package/lib/react-native/StorageController.react-native.js +11 -6
- package/lib/react-native/StorageController.weapp.js +6 -1
- package/lib/react-native/TaskQueue.js +8 -4
- package/lib/react-native/UniqueInstanceStateController.js +23 -37
- package/lib/react-native/WebSocketController.js +9 -1
- package/lib/react-native/Xhr.weapp.js +9 -4
- package/lib/react-native/unsavedChildren.js +3 -3
- package/lib/react-native/uuid.js +1 -2
- package/lib/weapp/Analytics.js +7 -11
- package/lib/weapp/AnonymousUtils.js +17 -22
- package/lib/weapp/Cloud.js +24 -46
- package/lib/weapp/CoreManager.js +71 -79
- package/lib/weapp/CryptoController.js +14 -9
- package/lib/weapp/EventEmitter.js +9 -2
- package/lib/weapp/EventuallyQueue.js +156 -357
- package/lib/weapp/FacebookUtils.js +23 -28
- package/lib/weapp/IndexedDBStorageController.js +18 -14
- package/lib/weapp/InstallationController.js +55 -121
- package/lib/weapp/LiveQueryClient.js +312 -446
- package/lib/weapp/LiveQuerySubscription.js +25 -28
- package/lib/weapp/LocalDatastore.js +254 -578
- package/lib/weapp/LocalDatastoreController.default.js +48 -227
- package/lib/weapp/LocalDatastoreController.js +11 -1
- package/lib/weapp/LocalDatastoreController.react-native.js +72 -164
- package/lib/weapp/LocalDatastoreUtils.js +4 -12
- package/lib/weapp/ObjectStateMutations.js +89 -95
- package/lib/weapp/OfflineQuery.js +106 -198
- package/lib/weapp/Parse.js +45 -60
- package/lib/weapp/ParseACL.js +242 -288
- package/lib/weapp/ParseCLP.js +372 -580
- package/lib/weapp/ParseConfig.js +115 -138
- package/lib/weapp/ParseError.js +85 -182
- package/lib/weapp/ParseFile.js +297 -446
- package/lib/weapp/ParseGeoPoint.js +121 -140
- package/lib/weapp/ParseHooks.js +12 -14
- package/lib/weapp/ParseInstallation.js +226 -354
- package/lib/weapp/ParseLiveQuery.js +74 -148
- package/lib/weapp/ParseObject.js +2017 -2622
- package/lib/weapp/ParseOp.js +343 -484
- package/lib/weapp/ParsePolygon.js +101 -120
- package/lib/weapp/ParseQuery.js +1722 -2068
- package/lib/weapp/ParseRelation.js +99 -118
- package/lib/weapp/ParseRole.js +88 -144
- package/lib/weapp/ParseSchema.js +372 -434
- package/lib/weapp/ParseSession.js +62 -110
- package/lib/weapp/ParseUser.js +942 -1270
- package/lib/weapp/Push.js +16 -44
- package/lib/weapp/RESTController.js +86 -125
- package/lib/weapp/SingleInstanceStateController.js +57 -86
- package/lib/weapp/Socket.weapp.js +50 -33
- package/lib/weapp/Storage.js +23 -28
- package/lib/weapp/StorageController.browser.js +16 -13
- package/lib/weapp/StorageController.default.js +15 -14
- package/lib/weapp/StorageController.js +14 -1
- package/lib/weapp/StorageController.react-native.js +31 -30
- package/lib/weapp/StorageController.weapp.js +19 -13
- package/lib/weapp/TaskQueue.js +37 -49
- package/lib/weapp/UniqueInstanceStateController.js +65 -86
- package/lib/weapp/WebSocketController.js +11 -4
- package/lib/weapp/Xhr.weapp.js +90 -78
- package/lib/weapp/arrayContainsObject.js +3 -3
- package/lib/weapp/canBeSerialized.js +10 -11
- package/lib/weapp/decode.js +11 -11
- package/lib/weapp/encode.js +11 -11
- package/lib/weapp/equals.js +9 -10
- package/lib/weapp/escape.js +2 -2
- package/lib/weapp/isRevocableSession.js +1 -1
- package/lib/weapp/parseDate.js +10 -10
- package/lib/weapp/promiseUtils.js +19 -19
- package/lib/weapp/unique.js +4 -4
- package/lib/weapp/unsavedChildren.js +20 -21
- package/lib/weapp/uuid.js +6 -8
- package/package.json +23 -30
package/lib/weapp/ParseUser.js
CHANGED
|
@@ -1,95 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
|
|
4
|
-
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
|
5
|
-
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
|
|
6
|
-
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
|
|
7
|
-
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
|
8
|
-
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
|
9
|
-
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
|
|
10
|
-
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
|
|
11
3
|
var _Object$defineProperty2 = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
12
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
13
5
|
_Object$defineProperty2(exports, "__esModule", {
|
|
14
6
|
value: true
|
|
15
7
|
});
|
|
16
8
|
exports.default = void 0;
|
|
17
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
|
|
18
9
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
19
|
-
var
|
|
10
|
+
var _defineProperty = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property"));
|
|
20
11
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
21
|
-
var _defineProperty3 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
22
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
|
23
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
24
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
25
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
26
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/get"));
|
|
27
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
|
|
28
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
|
|
29
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
|
|
30
12
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
31
13
|
var _isRevocableSession = _interopRequireDefault(require("./isRevocableSession"));
|
|
32
14
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
33
|
-
var
|
|
34
|
-
var _ParseSession = _interopRequireDefault(require("./ParseSession"));
|
|
15
|
+
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
35
16
|
var _Storage = _interopRequireDefault(require("./Storage"));
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
|
|
42
|
-
})), keys.push.apply(keys, symbols);
|
|
43
|
-
}
|
|
44
|
-
return keys;
|
|
45
|
-
}
|
|
46
|
-
function _objectSpread(target) {
|
|
47
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
48
|
-
var _context7, _context8;
|
|
49
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
50
|
-
i % 2 ? _forEachInstanceProperty(_context7 = ownKeys(Object(source), !0)).call(_context7, function (key) {
|
|
51
|
-
(0, _defineProperty3.default)(target, key, source[key]);
|
|
52
|
-
}) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context8 = ownKeys(Object(source))).call(_context8, function (key) {
|
|
53
|
-
_Object$defineProperty2(target, key, _Object$getOwnPropertyDescriptor(source, key));
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return target;
|
|
57
|
-
}
|
|
58
|
-
function _createSuper(Derived) {
|
|
59
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
60
|
-
return function () {
|
|
61
|
-
var Super = (0, _getPrototypeOf2.default)(Derived),
|
|
62
|
-
result;
|
|
63
|
-
if (hasNativeReflectConstruct) {
|
|
64
|
-
var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
|
|
65
|
-
result = _Reflect$construct(Super, arguments, NewTarget);
|
|
66
|
-
} else {
|
|
67
|
-
result = Super.apply(this, arguments);
|
|
68
|
-
}
|
|
69
|
-
return (0, _possibleConstructorReturn2.default)(this, result);
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function _isNativeReflectConstruct() {
|
|
73
|
-
if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
|
|
74
|
-
if (_Reflect$construct.sham) return false;
|
|
75
|
-
if (typeof Proxy === "function") return true;
|
|
76
|
-
try {
|
|
77
|
-
Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
|
|
78
|
-
return true;
|
|
79
|
-
} catch (e) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
} /**
|
|
83
|
-
* @flow
|
|
84
|
-
*/
|
|
85
|
-
/*:: import type { AttributeMap } from './ObjectStateMutations';*/
|
|
86
|
-
/*:: import type { RequestOptions, FullOptions } from './RESTController';*/
|
|
87
|
-
/*:: export type AuthData = ?{ [key: string]: mixed };*/
|
|
88
|
-
var CURRENT_USER_KEY = 'currentUser';
|
|
89
|
-
var canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
|
|
90
|
-
var currentUserCacheMatchesDisk = false;
|
|
91
|
-
var currentUserCache = null;
|
|
92
|
-
var authProviders = {};
|
|
17
|
+
const CURRENT_USER_KEY = 'currentUser';
|
|
18
|
+
let canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
|
|
19
|
+
let currentUserCacheMatchesDisk = false;
|
|
20
|
+
let currentUserCache = null;
|
|
21
|
+
const authProviders = {};
|
|
93
22
|
|
|
94
23
|
/**
|
|
95
24
|
* <p>A Parse.User object is a local representation of a user persisted to the
|
|
@@ -101,22 +30,17 @@ var authProviders = {};
|
|
|
101
30
|
* @alias Parse.User
|
|
102
31
|
* @augments Parse.Object
|
|
103
32
|
*/
|
|
104
|
-
|
|
105
|
-
(0, _inherits2.default)(ParseUser, _ParseObject);
|
|
106
|
-
var _super = _createSuper(ParseUser);
|
|
33
|
+
class ParseUser extends _ParseObject.default {
|
|
107
34
|
/**
|
|
108
35
|
* @param {object} attributes The initial set of data to store in the user.
|
|
109
36
|
*/
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
(
|
|
113
|
-
|
|
114
|
-
if (attributes && (0, _typeof2.default)(attributes) === 'object') {
|
|
115
|
-
if (!_this.set(attributes || {})) {
|
|
37
|
+
constructor(attributes) {
|
|
38
|
+
super('_User');
|
|
39
|
+
if (attributes && typeof attributes === 'object') {
|
|
40
|
+
if (!this.set(attributes || {})) {
|
|
116
41
|
throw new Error("Can't create an invalid Parse User");
|
|
117
42
|
}
|
|
118
43
|
}
|
|
119
|
-
return _this;
|
|
120
44
|
}
|
|
121
45
|
|
|
122
46
|
/**
|
|
@@ -126,1190 +50,963 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
|
|
|
126
50
|
* @returns {Promise} A promise that is resolved when the replacement
|
|
127
51
|
* token has been fetched.
|
|
128
52
|
*/
|
|
129
|
-
(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return controller.upgradeToRevocableSession(this, upgradeOptions);
|
|
139
|
-
}
|
|
53
|
+
_upgradeToRevocableSession(options) {
|
|
54
|
+
options = options || {};
|
|
55
|
+
const upgradeOptions = {};
|
|
56
|
+
if (options.hasOwnProperty('useMasterKey')) {
|
|
57
|
+
upgradeOptions.useMasterKey = options.useMasterKey;
|
|
58
|
+
}
|
|
59
|
+
const controller = _CoreManager.default.getUserController();
|
|
60
|
+
return controller.upgradeToRevocableSession(this, upgradeOptions);
|
|
61
|
+
}
|
|
140
62
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
if (authProviders[provider]) {
|
|
166
|
-
provider = authProviders[provider];
|
|
167
|
-
} else {
|
|
168
|
-
var authProvider = {
|
|
169
|
-
restoreAuthentication: function () {
|
|
170
|
-
return true;
|
|
171
|
-
},
|
|
172
|
-
getAuthType: function () {
|
|
173
|
-
return authType;
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
authProviders[authProvider.getAuthType()] = authProvider;
|
|
177
|
-
provider = authProvider;
|
|
178
|
-
}
|
|
63
|
+
/**
|
|
64
|
+
* Parse allows you to link your users with {@link https://docs.parseplatform.org/parse-server/guide/#oauth-and-3rd-party-authentication 3rd party authentication}, enabling
|
|
65
|
+
* your users to sign up or log into your application using their existing identities.
|
|
66
|
+
* Since 2.9.0
|
|
67
|
+
*
|
|
68
|
+
* @see {@link https://docs.parseplatform.org/js/guide/#linking-users Linking Users}
|
|
69
|
+
* @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
|
|
70
|
+
* @param {object} options
|
|
71
|
+
* @param {object} [options.authData] AuthData to link with
|
|
72
|
+
* <ul>
|
|
73
|
+
* <li>If provider is string, options is {@link http://docs.parseplatform.org/parse-server/guide/#supported-3rd-party-authentications authData}
|
|
74
|
+
* <li>If provider is AuthProvider, options is saveOpts
|
|
75
|
+
* </ul>
|
|
76
|
+
* @param {object} saveOpts useMasterKey / sessionToken
|
|
77
|
+
* @returns {Promise} A promise that is fulfilled with the user is linked
|
|
78
|
+
*/
|
|
79
|
+
linkWith(provider, options) {
|
|
80
|
+
let saveOpts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
81
|
+
saveOpts.sessionToken = saveOpts.sessionToken || this.getSessionToken() || '';
|
|
82
|
+
let authType;
|
|
83
|
+
if (typeof provider === 'string') {
|
|
84
|
+
authType = provider;
|
|
85
|
+
if (authProviders[provider]) {
|
|
86
|
+
provider = authProviders[provider];
|
|
179
87
|
} else {
|
|
180
|
-
|
|
88
|
+
const authProvider = {
|
|
89
|
+
restoreAuthentication() {
|
|
90
|
+
return true;
|
|
91
|
+
},
|
|
92
|
+
getAuthType() {
|
|
93
|
+
return authType;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
authProviders[authProvider.getAuthType()] = authProvider;
|
|
97
|
+
provider = authProvider;
|
|
181
98
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
this.stripAnonymity();
|
|
190
|
-
var controller = _CoreManager.default.getUserController();
|
|
191
|
-
return controller.linkWith(this, authData, saveOpts).catch(function (e) {
|
|
192
|
-
delete authData[authType];
|
|
193
|
-
_this2.restoreAnonimity(oldAnonymousData);
|
|
194
|
-
throw e;
|
|
195
|
-
});
|
|
196
|
-
} else {
|
|
197
|
-
return new _promise.default(function (resolve, reject) {
|
|
198
|
-
provider.authenticate({
|
|
199
|
-
success: function (provider, result) {
|
|
200
|
-
var opts = {};
|
|
201
|
-
opts.authData = result;
|
|
202
|
-
_this2.linkWith(provider, opts, saveOpts).then(function () {
|
|
203
|
-
resolve(_this2);
|
|
204
|
-
}, function (error) {
|
|
205
|
-
reject(error);
|
|
206
|
-
});
|
|
207
|
-
},
|
|
208
|
-
error: function (provider, _error) {
|
|
209
|
-
reject(_error);
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
});
|
|
99
|
+
} else {
|
|
100
|
+
authType = provider.getAuthType();
|
|
101
|
+
}
|
|
102
|
+
if (options && options.hasOwnProperty('authData')) {
|
|
103
|
+
const authData = this.get('authData') || {};
|
|
104
|
+
if (typeof authData !== 'object') {
|
|
105
|
+
throw new Error('Invalid type: authData field should be an object');
|
|
213
106
|
}
|
|
107
|
+
authData[authType] = options.authData;
|
|
108
|
+
const oldAnonymousData = authData.anonymous;
|
|
109
|
+
this.stripAnonymity();
|
|
110
|
+
const controller = _CoreManager.default.getUserController();
|
|
111
|
+
return controller.linkWith(this, authData, saveOpts).catch(e => {
|
|
112
|
+
delete authData[authType];
|
|
113
|
+
this.restoreAnonimity(oldAnonymousData);
|
|
114
|
+
throw e;
|
|
115
|
+
});
|
|
116
|
+
} else {
|
|
117
|
+
return new _promise.default((resolve, reject) => {
|
|
118
|
+
provider.authenticate({
|
|
119
|
+
success: (provider, result) => {
|
|
120
|
+
const opts = {};
|
|
121
|
+
opts.authData = result;
|
|
122
|
+
this.linkWith(provider, opts, saveOpts).then(() => {
|
|
123
|
+
resolve(this);
|
|
124
|
+
}, error => {
|
|
125
|
+
reject(error);
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
error: (provider, error) => {
|
|
129
|
+
reject(error);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
});
|
|
214
133
|
}
|
|
134
|
+
}
|
|
215
135
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
136
|
+
/**
|
|
137
|
+
* @param provider
|
|
138
|
+
* @param options
|
|
139
|
+
* @param {object} [options.authData]
|
|
140
|
+
* @param saveOpts
|
|
141
|
+
* @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
|
|
142
|
+
* @returns {Promise}
|
|
143
|
+
*/
|
|
144
|
+
_linkWith(provider, options) {
|
|
145
|
+
let saveOpts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
146
|
+
return this.linkWith(provider, options, saveOpts);
|
|
147
|
+
}
|
|
229
148
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
} else {
|
|
247
|
-
authType = provider.getAuthType();
|
|
248
|
-
}
|
|
249
|
-
var authData = this.get('authData');
|
|
250
|
-
if (!provider || !authData || (0, _typeof2.default)(authData) !== 'object') {
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
var success = provider.restoreAuthentication(authData[authType]);
|
|
254
|
-
if (!success) {
|
|
255
|
-
this._unlinkFrom(provider);
|
|
256
|
-
}
|
|
149
|
+
/**
|
|
150
|
+
* Synchronizes auth data for a provider (e.g. puts the access token in the
|
|
151
|
+
* right place to be used by the Facebook SDK).
|
|
152
|
+
*
|
|
153
|
+
* @param provider
|
|
154
|
+
*/
|
|
155
|
+
_synchronizeAuthData(provider) {
|
|
156
|
+
if (!this.isCurrent() || !provider) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
let authType;
|
|
160
|
+
if (typeof provider === 'string') {
|
|
161
|
+
authType = provider;
|
|
162
|
+
provider = authProviders[authType];
|
|
163
|
+
} else {
|
|
164
|
+
authType = provider.getAuthType();
|
|
257
165
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
*/
|
|
262
|
-
}, {
|
|
263
|
-
key: "_synchronizeAllAuthData",
|
|
264
|
-
value: function () {
|
|
265
|
-
var authData = this.get('authData');
|
|
266
|
-
if ((0, _typeof2.default)(authData) !== 'object') {
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
for (var _key in authData) {
|
|
270
|
-
this._synchronizeAuthData(_key);
|
|
271
|
-
}
|
|
166
|
+
const authData = this.get('authData');
|
|
167
|
+
if (!provider || !authData || typeof authData !== 'object') {
|
|
168
|
+
return;
|
|
272
169
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
*/
|
|
277
|
-
}, {
|
|
278
|
-
key: "_cleanupAuthData",
|
|
279
|
-
value: function () {
|
|
280
|
-
if (!this.isCurrent()) {
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
var authData = this.get('authData');
|
|
284
|
-
if ((0, _typeof2.default)(authData) !== 'object') {
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
for (var _key2 in authData) {
|
|
288
|
-
if (!authData[_key2]) {
|
|
289
|
-
delete authData[_key2];
|
|
290
|
-
}
|
|
291
|
-
}
|
|
170
|
+
const success = provider.restoreAuthentication(authData[authType]);
|
|
171
|
+
if (!success) {
|
|
172
|
+
this._unlinkFrom(provider);
|
|
292
173
|
}
|
|
174
|
+
}
|
|
293
175
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
*/
|
|
302
|
-
}, {
|
|
303
|
-
key: "_unlinkFrom",
|
|
304
|
-
value: function (provider /*: any*/, options /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
|
|
305
|
-
var _this3 = this;
|
|
306
|
-
return this.linkWith(provider, {
|
|
307
|
-
authData: null
|
|
308
|
-
}, options).then(function () {
|
|
309
|
-
_this3._synchronizeAuthData(provider);
|
|
310
|
-
return _promise.default.resolve(_this3);
|
|
311
|
-
});
|
|
176
|
+
/**
|
|
177
|
+
* Synchronizes authData for all providers.
|
|
178
|
+
*/
|
|
179
|
+
_synchronizeAllAuthData() {
|
|
180
|
+
const authData = this.get('authData');
|
|
181
|
+
if (typeof authData !== 'object') {
|
|
182
|
+
return;
|
|
312
183
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
* Checks whether a user is linked to a service.
|
|
316
|
-
*
|
|
317
|
-
* @param {object} provider service to link to
|
|
318
|
-
* @returns {boolean} true if link was successful
|
|
319
|
-
*/
|
|
320
|
-
}, {
|
|
321
|
-
key: "_isLinked",
|
|
322
|
-
value: function (provider /*: any*/) /*: boolean*/{
|
|
323
|
-
var authType;
|
|
324
|
-
if (typeof provider === 'string') {
|
|
325
|
-
authType = provider;
|
|
326
|
-
} else {
|
|
327
|
-
authType = provider.getAuthType();
|
|
328
|
-
}
|
|
329
|
-
var authData = this.get('authData') || {};
|
|
330
|
-
if ((0, _typeof2.default)(authData) !== 'object') {
|
|
331
|
-
return false;
|
|
332
|
-
}
|
|
333
|
-
return !!authData[authType];
|
|
184
|
+
for (const key in authData) {
|
|
185
|
+
this._synchronizeAuthData(key);
|
|
334
186
|
}
|
|
187
|
+
}
|
|
335
188
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
var authData = this.get('authData');
|
|
343
|
-
if ((0, _typeof2.default)(authData) !== 'object') {
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
for (var _key3 in authData) {
|
|
347
|
-
this._logOutWith(_key3);
|
|
348
|
-
}
|
|
189
|
+
/**
|
|
190
|
+
* Removes null values from authData (which exist temporarily for unlinking)
|
|
191
|
+
*/
|
|
192
|
+
_cleanupAuthData() {
|
|
193
|
+
if (!this.isCurrent()) {
|
|
194
|
+
return;
|
|
349
195
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}, {
|
|
358
|
-
key: "_logOutWith",
|
|
359
|
-
value: function (provider /*: any*/) {
|
|
360
|
-
if (!this.isCurrent()) {
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
363
|
-
if (typeof provider === 'string') {
|
|
364
|
-
provider = authProviders[provider];
|
|
365
|
-
}
|
|
366
|
-
if (provider && provider.deauthenticate) {
|
|
367
|
-
provider.deauthenticate();
|
|
196
|
+
const authData = this.get('authData');
|
|
197
|
+
if (typeof authData !== 'object') {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
for (const key in authData) {
|
|
201
|
+
if (!authData[key]) {
|
|
202
|
+
delete authData[key];
|
|
368
203
|
}
|
|
369
204
|
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Unlinks a user from a service.
|
|
209
|
+
*
|
|
210
|
+
* @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
|
|
211
|
+
* @param {object} options MasterKey / SessionToken
|
|
212
|
+
* @returns {Promise} A promise that is fulfilled when the unlinking
|
|
213
|
+
* finishes.
|
|
214
|
+
*/
|
|
215
|
+
_unlinkFrom(provider, options) {
|
|
216
|
+
return this.linkWith(provider, {
|
|
217
|
+
authData: null
|
|
218
|
+
}, options).then(() => {
|
|
219
|
+
this._synchronizeAuthData(provider);
|
|
220
|
+
return _promise.default.resolve(this);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
370
223
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Checks whether a user is linked to a service.
|
|
226
|
+
*
|
|
227
|
+
* @param {object} provider service to link to
|
|
228
|
+
* @returns {boolean} true if link was successful
|
|
229
|
+
*/
|
|
230
|
+
_isLinked(provider) {
|
|
231
|
+
let authType;
|
|
232
|
+
if (typeof provider === 'string') {
|
|
233
|
+
authType = provider;
|
|
234
|
+
} else {
|
|
235
|
+
authType = provider.getAuthType();
|
|
236
|
+
}
|
|
237
|
+
const authData = this.get('authData') || {};
|
|
238
|
+
if (typeof authData !== 'object') {
|
|
239
|
+
return false;
|
|
383
240
|
}
|
|
241
|
+
return !!authData[authType];
|
|
242
|
+
}
|
|
384
243
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
244
|
+
/**
|
|
245
|
+
* Deauthenticates all providers.
|
|
246
|
+
*/
|
|
247
|
+
_logOutWithAll() {
|
|
248
|
+
const authData = this.get('authData');
|
|
249
|
+
if (typeof authData !== 'object') {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
for (const key in authData) {
|
|
253
|
+
this._logOutWith(key);
|
|
395
254
|
}
|
|
255
|
+
}
|
|
396
256
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
var current;
|
|
407
|
-
return _regenerator.default.wrap(function (_context) {
|
|
408
|
-
while (1) switch (_context.prev = _context.next) {
|
|
409
|
-
case 0:
|
|
410
|
-
_context.next = 2;
|
|
411
|
-
return ParseUser.currentAsync();
|
|
412
|
-
case 2:
|
|
413
|
-
current = _context.sent;
|
|
414
|
-
return _context.abrupt("return", !!current && current.id === this.id);
|
|
415
|
-
case 4:
|
|
416
|
-
case "end":
|
|
417
|
-
return _context.stop();
|
|
418
|
-
}
|
|
419
|
-
}, _callee, this);
|
|
420
|
-
}));
|
|
421
|
-
function isCurrentAsync() {
|
|
422
|
-
return _isCurrentAsync.apply(this, arguments);
|
|
423
|
-
}
|
|
424
|
-
return isCurrentAsync;
|
|
425
|
-
}()
|
|
426
|
-
}, {
|
|
427
|
-
key: "stripAnonymity",
|
|
428
|
-
value: function () {
|
|
429
|
-
var authData = this.get('authData');
|
|
430
|
-
if (authData && (0, _typeof2.default)(authData) === 'object' && authData.hasOwnProperty('anonymous')) {
|
|
431
|
-
// We need to set anonymous to null instead of deleting it in order to remove it from Parse.
|
|
432
|
-
authData.anonymous = null;
|
|
433
|
-
}
|
|
257
|
+
/**
|
|
258
|
+
* Deauthenticates a single provider (e.g. removing access tokens from the
|
|
259
|
+
* Facebook SDK).
|
|
260
|
+
*
|
|
261
|
+
* @param {object} provider service to logout of
|
|
262
|
+
*/
|
|
263
|
+
_logOutWith(provider) {
|
|
264
|
+
if (!this.isCurrent()) {
|
|
265
|
+
return;
|
|
434
266
|
}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
value: function (anonymousData /*: any*/) {
|
|
438
|
-
if (anonymousData) {
|
|
439
|
-
var authData = this.get('authData');
|
|
440
|
-
authData.anonymous = anonymousData;
|
|
441
|
-
}
|
|
267
|
+
if (typeof provider === 'string') {
|
|
268
|
+
provider = authProviders[provider];
|
|
442
269
|
}
|
|
270
|
+
if (provider && provider.deauthenticate) {
|
|
271
|
+
provider.deauthenticate();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
443
274
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
275
|
+
/**
|
|
276
|
+
* Class instance method used to maintain specific keys when a fetch occurs.
|
|
277
|
+
* Used to ensure that the session token is not lost.
|
|
278
|
+
*
|
|
279
|
+
* @returns {object} sessionToken
|
|
280
|
+
*/
|
|
281
|
+
_preserveFieldsOnFetch() {
|
|
282
|
+
return {
|
|
283
|
+
sessionToken: this.get('sessionToken')
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Returns true if <code>current</code> would return this user.
|
|
289
|
+
*
|
|
290
|
+
* @returns {boolean} true if user is cached on disk
|
|
291
|
+
*/
|
|
292
|
+
isCurrent() {
|
|
293
|
+
const current = ParseUser.current();
|
|
294
|
+
return !!current && current.id === this.id;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Returns true if <code>current</code> would return this user.
|
|
299
|
+
*
|
|
300
|
+
* @returns {Promise<boolean>} true if user is cached on disk
|
|
301
|
+
*/
|
|
302
|
+
async isCurrentAsync() {
|
|
303
|
+
const current = await ParseUser.currentAsync();
|
|
304
|
+
return !!current && current.id === this.id;
|
|
305
|
+
}
|
|
306
|
+
stripAnonymity() {
|
|
307
|
+
const authData = this.get('authData');
|
|
308
|
+
if (authData && typeof authData === 'object' && authData.hasOwnProperty('anonymous')) {
|
|
309
|
+
// We need to set anonymous to null instead of deleting it in order to remove it from Parse.
|
|
310
|
+
authData.anonymous = null;
|
|
457
311
|
}
|
|
312
|
+
}
|
|
313
|
+
restoreAnonimity(anonymousData) {
|
|
314
|
+
if (anonymousData) {
|
|
315
|
+
const authData = this.get('authData');
|
|
316
|
+
authData.anonymous = anonymousData;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
458
319
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
this.set('username', username);
|
|
320
|
+
/**
|
|
321
|
+
* Returns get("username").
|
|
322
|
+
*
|
|
323
|
+
* @returns {string}
|
|
324
|
+
*/
|
|
325
|
+
getUsername() {
|
|
326
|
+
const username = this.get('username');
|
|
327
|
+
if (username == null || typeof username === 'string') {
|
|
328
|
+
return username;
|
|
469
329
|
}
|
|
330
|
+
return '';
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Calls set("username", username, options) and returns the result.
|
|
335
|
+
*
|
|
336
|
+
* @param {string} username
|
|
337
|
+
*/
|
|
338
|
+
setUsername(username) {
|
|
339
|
+
this.stripAnonymity();
|
|
340
|
+
this.set('username', username);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Calls set("password", password, options) and returns the result.
|
|
345
|
+
*
|
|
346
|
+
* @param {string} password User's Password
|
|
347
|
+
*/
|
|
348
|
+
setPassword(password) {
|
|
349
|
+
this.set('password', password);
|
|
350
|
+
}
|
|
470
351
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
352
|
+
/**
|
|
353
|
+
* Returns get("email").
|
|
354
|
+
*
|
|
355
|
+
* @returns {string} User's Email
|
|
356
|
+
*/
|
|
357
|
+
getEmail() {
|
|
358
|
+
const email = this.get('email');
|
|
359
|
+
if (email == null || typeof email === 'string') {
|
|
360
|
+
return email;
|
|
480
361
|
}
|
|
362
|
+
return '';
|
|
363
|
+
}
|
|
481
364
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
365
|
+
/**
|
|
366
|
+
* Calls set("email", email) and returns the result.
|
|
367
|
+
*
|
|
368
|
+
* @param {string} email
|
|
369
|
+
* @returns {boolean}
|
|
370
|
+
*/
|
|
371
|
+
setEmail(email) {
|
|
372
|
+
return this.set('email', email);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Returns the session token for this user, if the user has been logged in,
|
|
377
|
+
* or if it is the result of a query with the master key. Otherwise, returns
|
|
378
|
+
* undefined.
|
|
379
|
+
*
|
|
380
|
+
* @returns {string} the session token, or undefined
|
|
381
|
+
*/
|
|
382
|
+
getSessionToken() {
|
|
383
|
+
const token = this.get('sessionToken');
|
|
384
|
+
if (token == null || typeof token === 'string') {
|
|
385
|
+
return token;
|
|
495
386
|
}
|
|
387
|
+
return '';
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Checks whether this user is the current user and has been authenticated.
|
|
392
|
+
*
|
|
393
|
+
* @returns {boolean} whether this user is the current user and is logged in.
|
|
394
|
+
*/
|
|
395
|
+
authenticated() {
|
|
396
|
+
const current = ParseUser.current();
|
|
397
|
+
return !!this.get('sessionToken') && !!current && current.id === this.id;
|
|
398
|
+
}
|
|
496
399
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
400
|
+
/**
|
|
401
|
+
* Signs up a new user. You should call this instead of save for
|
|
402
|
+
* new Parse.Users. This will create a new Parse.User on the server, and
|
|
403
|
+
* also persist the session on disk so that you can access the user using
|
|
404
|
+
* <code>current</code>.
|
|
405
|
+
*
|
|
406
|
+
* <p>A username and password must be set before calling signUp.</p>
|
|
407
|
+
*
|
|
408
|
+
* @param {object} attrs Extra fields to set on the new user, or null.
|
|
409
|
+
* @param {object} options
|
|
410
|
+
* @returns {Promise} A promise that is fulfilled when the signup
|
|
411
|
+
* finishes.
|
|
412
|
+
*/
|
|
413
|
+
signUp(attrs, options) {
|
|
414
|
+
options = options || {};
|
|
415
|
+
const signupOptions = {};
|
|
416
|
+
if (options.hasOwnProperty('useMasterKey')) {
|
|
417
|
+
signupOptions.useMasterKey = options.useMasterKey;
|
|
507
418
|
}
|
|
419
|
+
if (options.hasOwnProperty('installationId')) {
|
|
420
|
+
signupOptions.installationId = options.installationId;
|
|
421
|
+
}
|
|
422
|
+
if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
|
|
423
|
+
signupOptions.context = options.context;
|
|
424
|
+
}
|
|
425
|
+
const controller = _CoreManager.default.getUserController();
|
|
426
|
+
return controller.signUp(this, attrs, signupOptions);
|
|
427
|
+
}
|
|
508
428
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
429
|
+
/**
|
|
430
|
+
* Logs in a Parse.User. On success, this saves the session to disk,
|
|
431
|
+
* so you can retrieve the currently logged in user using
|
|
432
|
+
* <code>current</code>.
|
|
433
|
+
*
|
|
434
|
+
* <p>A username and password must be set before calling logIn.</p>
|
|
435
|
+
*
|
|
436
|
+
* @param {object} options
|
|
437
|
+
* @returns {Promise} A promise that is fulfilled with the user when
|
|
438
|
+
* the login is complete.
|
|
439
|
+
*/
|
|
440
|
+
logIn() {
|
|
441
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
442
|
+
options = options || {};
|
|
443
|
+
const loginOptions = {
|
|
444
|
+
usePost: true
|
|
445
|
+
};
|
|
446
|
+
if (options.hasOwnProperty('useMasterKey')) {
|
|
447
|
+
loginOptions.useMasterKey = options.useMasterKey;
|
|
448
|
+
}
|
|
449
|
+
if (options.hasOwnProperty('installationId')) {
|
|
450
|
+
loginOptions.installationId = options.installationId;
|
|
451
|
+
}
|
|
452
|
+
if (options.hasOwnProperty('usePost')) {
|
|
453
|
+
loginOptions.usePost = options.usePost;
|
|
524
454
|
}
|
|
455
|
+
if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
|
|
456
|
+
loginOptions.context = options.context;
|
|
457
|
+
}
|
|
458
|
+
const controller = _CoreManager.default.getUserController();
|
|
459
|
+
return controller.logIn(this, loginOptions);
|
|
460
|
+
}
|
|
525
461
|
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
462
|
+
/**
|
|
463
|
+
* Wrap the default save behavior with functionality to save to local
|
|
464
|
+
* storage if this is current user.
|
|
465
|
+
*
|
|
466
|
+
* @param {...any} args
|
|
467
|
+
* @returns {Promise}
|
|
468
|
+
*/
|
|
469
|
+
async save() {
|
|
470
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
471
|
+
args[_key] = arguments[_key];
|
|
472
|
+
}
|
|
473
|
+
await super.save.apply(this, args);
|
|
474
|
+
const current = await this.isCurrentAsync();
|
|
475
|
+
if (current) {
|
|
476
|
+
return _CoreManager.default.getUserController().updateUserOnDisk(this);
|
|
536
477
|
}
|
|
478
|
+
return this;
|
|
479
|
+
}
|
|
537
480
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
value: function (attrs /*: AttributeMap*/, options /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
|
|
554
|
-
options = options || {};
|
|
555
|
-
var signupOptions = {};
|
|
556
|
-
if (options.hasOwnProperty('useMasterKey')) {
|
|
557
|
-
signupOptions.useMasterKey = options.useMasterKey;
|
|
558
|
-
}
|
|
559
|
-
if (options.hasOwnProperty('installationId')) {
|
|
560
|
-
signupOptions.installationId = options.installationId;
|
|
561
|
-
}
|
|
562
|
-
if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
|
|
563
|
-
signupOptions.context = options.context;
|
|
564
|
-
}
|
|
565
|
-
var controller = _CoreManager.default.getUserController();
|
|
566
|
-
return controller.signUp(this, attrs, signupOptions);
|
|
481
|
+
/**
|
|
482
|
+
* Wrap the default destroy behavior with functionality that logs out
|
|
483
|
+
* the current user when it is destroyed
|
|
484
|
+
*
|
|
485
|
+
* @param {...any} args
|
|
486
|
+
* @returns {Parse.User}
|
|
487
|
+
*/
|
|
488
|
+
async destroy() {
|
|
489
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
490
|
+
args[_key2] = arguments[_key2];
|
|
491
|
+
}
|
|
492
|
+
await super.destroy.apply(this, args);
|
|
493
|
+
const current = await this.isCurrentAsync();
|
|
494
|
+
if (current) {
|
|
495
|
+
return _CoreManager.default.getUserController().removeUserFromDisk();
|
|
567
496
|
}
|
|
497
|
+
return this;
|
|
498
|
+
}
|
|
568
499
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
var loginOptions = {
|
|
585
|
-
usePost: true
|
|
586
|
-
};
|
|
587
|
-
if (options.hasOwnProperty('useMasterKey')) {
|
|
588
|
-
loginOptions.useMasterKey = options.useMasterKey;
|
|
589
|
-
}
|
|
590
|
-
if (options.hasOwnProperty('installationId')) {
|
|
591
|
-
loginOptions.installationId = options.installationId;
|
|
592
|
-
}
|
|
593
|
-
if (options.hasOwnProperty('usePost')) {
|
|
594
|
-
loginOptions.usePost = options.usePost;
|
|
595
|
-
}
|
|
596
|
-
if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
|
|
597
|
-
loginOptions.context = options.context;
|
|
598
|
-
}
|
|
599
|
-
var controller = _CoreManager.default.getUserController();
|
|
600
|
-
return controller.logIn(this, loginOptions);
|
|
500
|
+
/**
|
|
501
|
+
* Wrap the default fetch behavior with functionality to save to local
|
|
502
|
+
* storage if this is current user.
|
|
503
|
+
*
|
|
504
|
+
* @param {...any} args
|
|
505
|
+
* @returns {Parse.User}
|
|
506
|
+
*/
|
|
507
|
+
async fetch() {
|
|
508
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
509
|
+
args[_key3] = arguments[_key3];
|
|
510
|
+
}
|
|
511
|
+
await super.fetch.apply(this, args);
|
|
512
|
+
const current = await this.isCurrentAsync();
|
|
513
|
+
if (current) {
|
|
514
|
+
return _CoreManager.default.getUserController().updateUserOnDisk(this);
|
|
601
515
|
}
|
|
516
|
+
return this;
|
|
517
|
+
}
|
|
602
518
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
var _save = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
614
|
-
var _len,
|
|
615
|
-
args,
|
|
616
|
-
_key4,
|
|
617
|
-
current,
|
|
618
|
-
_args2 = arguments;
|
|
619
|
-
return _regenerator.default.wrap(function (_context2) {
|
|
620
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
621
|
-
case 0:
|
|
622
|
-
for (_len = _args2.length, args = new Array(_len), _key4 = 0; _key4 < _len; _key4++) {
|
|
623
|
-
args[_key4] = _args2[_key4];
|
|
624
|
-
}
|
|
625
|
-
_context2.next = 3;
|
|
626
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "save", this).apply(this, args);
|
|
627
|
-
case 3:
|
|
628
|
-
_context2.next = 5;
|
|
629
|
-
return this.isCurrentAsync();
|
|
630
|
-
case 5:
|
|
631
|
-
current = _context2.sent;
|
|
632
|
-
if (!current) {
|
|
633
|
-
_context2.next = 8;
|
|
634
|
-
break;
|
|
635
|
-
}
|
|
636
|
-
return _context2.abrupt("return", _CoreManager.default.getUserController().updateUserOnDisk(this));
|
|
637
|
-
case 8:
|
|
638
|
-
return _context2.abrupt("return", this);
|
|
639
|
-
case 9:
|
|
640
|
-
case "end":
|
|
641
|
-
return _context2.stop();
|
|
642
|
-
}
|
|
643
|
-
}, _callee2, this);
|
|
644
|
-
}));
|
|
645
|
-
function save() {
|
|
646
|
-
return _save.apply(this, arguments);
|
|
647
|
-
}
|
|
648
|
-
return save;
|
|
649
|
-
}()
|
|
650
|
-
/**
|
|
651
|
-
* Wrap the default destroy behavior with functionality that logs out
|
|
652
|
-
* the current user when it is destroyed
|
|
653
|
-
*
|
|
654
|
-
* @param {...any} args
|
|
655
|
-
* @returns {Parse.User}
|
|
656
|
-
*/
|
|
657
|
-
}, {
|
|
658
|
-
key: "destroy",
|
|
659
|
-
value: function () {
|
|
660
|
-
var _destroy = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
661
|
-
var _len2,
|
|
662
|
-
args,
|
|
663
|
-
_key5,
|
|
664
|
-
current,
|
|
665
|
-
_args3 = arguments;
|
|
666
|
-
return _regenerator.default.wrap(function (_context3) {
|
|
667
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
668
|
-
case 0:
|
|
669
|
-
for (_len2 = _args3.length, args = new Array(_len2), _key5 = 0; _key5 < _len2; _key5++) {
|
|
670
|
-
args[_key5] = _args3[_key5];
|
|
671
|
-
}
|
|
672
|
-
_context3.next = 3;
|
|
673
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "destroy", this).apply(this, args);
|
|
674
|
-
case 3:
|
|
675
|
-
_context3.next = 5;
|
|
676
|
-
return this.isCurrentAsync();
|
|
677
|
-
case 5:
|
|
678
|
-
current = _context3.sent;
|
|
679
|
-
if (!current) {
|
|
680
|
-
_context3.next = 8;
|
|
681
|
-
break;
|
|
682
|
-
}
|
|
683
|
-
return _context3.abrupt("return", _CoreManager.default.getUserController().removeUserFromDisk());
|
|
684
|
-
case 8:
|
|
685
|
-
return _context3.abrupt("return", this);
|
|
686
|
-
case 9:
|
|
687
|
-
case "end":
|
|
688
|
-
return _context3.stop();
|
|
689
|
-
}
|
|
690
|
-
}, _callee3, this);
|
|
691
|
-
}));
|
|
692
|
-
function destroy() {
|
|
693
|
-
return _destroy.apply(this, arguments);
|
|
694
|
-
}
|
|
695
|
-
return destroy;
|
|
696
|
-
}()
|
|
697
|
-
/**
|
|
698
|
-
* Wrap the default fetch behavior with functionality to save to local
|
|
699
|
-
* storage if this is current user.
|
|
700
|
-
*
|
|
701
|
-
* @param {...any} args
|
|
702
|
-
* @returns {Parse.User}
|
|
703
|
-
*/
|
|
704
|
-
}, {
|
|
705
|
-
key: "fetch",
|
|
706
|
-
value: function () {
|
|
707
|
-
var _fetch = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
708
|
-
var _len3,
|
|
709
|
-
args,
|
|
710
|
-
_key6,
|
|
711
|
-
current,
|
|
712
|
-
_args4 = arguments;
|
|
713
|
-
return _regenerator.default.wrap(function (_context4) {
|
|
714
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
715
|
-
case 0:
|
|
716
|
-
for (_len3 = _args4.length, args = new Array(_len3), _key6 = 0; _key6 < _len3; _key6++) {
|
|
717
|
-
args[_key6] = _args4[_key6];
|
|
718
|
-
}
|
|
719
|
-
_context4.next = 3;
|
|
720
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetch", this).apply(this, args);
|
|
721
|
-
case 3:
|
|
722
|
-
_context4.next = 5;
|
|
723
|
-
return this.isCurrentAsync();
|
|
724
|
-
case 5:
|
|
725
|
-
current = _context4.sent;
|
|
726
|
-
if (!current) {
|
|
727
|
-
_context4.next = 8;
|
|
728
|
-
break;
|
|
729
|
-
}
|
|
730
|
-
return _context4.abrupt("return", _CoreManager.default.getUserController().updateUserOnDisk(this));
|
|
731
|
-
case 8:
|
|
732
|
-
return _context4.abrupt("return", this);
|
|
733
|
-
case 9:
|
|
734
|
-
case "end":
|
|
735
|
-
return _context4.stop();
|
|
736
|
-
}
|
|
737
|
-
}, _callee4, this);
|
|
738
|
-
}));
|
|
739
|
-
function fetch() {
|
|
740
|
-
return _fetch.apply(this, arguments);
|
|
741
|
-
}
|
|
742
|
-
return fetch;
|
|
743
|
-
}()
|
|
744
|
-
/**
|
|
745
|
-
* Wrap the default fetchWithInclude behavior with functionality to save to local
|
|
746
|
-
* storage if this is current user.
|
|
747
|
-
*
|
|
748
|
-
* @param {...any} args
|
|
749
|
-
* @returns {Parse.User}
|
|
750
|
-
*/
|
|
751
|
-
}, {
|
|
752
|
-
key: "fetchWithInclude",
|
|
753
|
-
value: function () {
|
|
754
|
-
var _fetchWithInclude = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
755
|
-
var _len4,
|
|
756
|
-
args,
|
|
757
|
-
_key7,
|
|
758
|
-
current,
|
|
759
|
-
_args5 = arguments;
|
|
760
|
-
return _regenerator.default.wrap(function (_context5) {
|
|
761
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
762
|
-
case 0:
|
|
763
|
-
for (_len4 = _args5.length, args = new Array(_len4), _key7 = 0; _key7 < _len4; _key7++) {
|
|
764
|
-
args[_key7] = _args5[_key7];
|
|
765
|
-
}
|
|
766
|
-
_context5.next = 3;
|
|
767
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetchWithInclude", this).apply(this, args);
|
|
768
|
-
case 3:
|
|
769
|
-
_context5.next = 5;
|
|
770
|
-
return this.isCurrentAsync();
|
|
771
|
-
case 5:
|
|
772
|
-
current = _context5.sent;
|
|
773
|
-
if (!current) {
|
|
774
|
-
_context5.next = 8;
|
|
775
|
-
break;
|
|
776
|
-
}
|
|
777
|
-
return _context5.abrupt("return", _CoreManager.default.getUserController().updateUserOnDisk(this));
|
|
778
|
-
case 8:
|
|
779
|
-
return _context5.abrupt("return", this);
|
|
780
|
-
case 9:
|
|
781
|
-
case "end":
|
|
782
|
-
return _context5.stop();
|
|
783
|
-
}
|
|
784
|
-
}, _callee5, this);
|
|
785
|
-
}));
|
|
786
|
-
function fetchWithInclude() {
|
|
787
|
-
return _fetchWithInclude.apply(this, arguments);
|
|
788
|
-
}
|
|
789
|
-
return fetchWithInclude;
|
|
790
|
-
}()
|
|
791
|
-
/**
|
|
792
|
-
* Verify whether a given password is the password of the current user.
|
|
793
|
-
*
|
|
794
|
-
* @param {string} password The password to be verified.
|
|
795
|
-
* @param {object} options The options.
|
|
796
|
-
* @param {boolean} [options.ignoreEmailVerification=false] Set to `true` to bypass email verification and verify
|
|
797
|
-
* the password regardless of whether the email has been verified. This requires the master key.
|
|
798
|
-
* @returns {Promise} A promise that is fulfilled with a user when the password is correct.
|
|
799
|
-
*/
|
|
800
|
-
}, {
|
|
801
|
-
key: "verifyPassword",
|
|
802
|
-
value: function (password /*: string*/, options /*:: ?: RequestOptions*/) /*: Promise<ParseUser>*/{
|
|
803
|
-
var username = this.getUsername() || '';
|
|
804
|
-
return ParseUser.verifyPassword(username, password, options);
|
|
805
|
-
}
|
|
806
|
-
}], [{
|
|
807
|
-
key: "readOnlyAttributes",
|
|
808
|
-
value: function () {
|
|
809
|
-
return ['sessionToken'];
|
|
519
|
+
/**
|
|
520
|
+
* Wrap the default fetchWithInclude behavior with functionality to save to local
|
|
521
|
+
* storage if this is current user.
|
|
522
|
+
*
|
|
523
|
+
* @param {...any} args
|
|
524
|
+
* @returns {Parse.User}
|
|
525
|
+
*/
|
|
526
|
+
async fetchWithInclude() {
|
|
527
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
528
|
+
args[_key4] = arguments[_key4];
|
|
810
529
|
}
|
|
530
|
+
await super.fetchWithInclude.apply(this, args);
|
|
531
|
+
const current = await this.isCurrentAsync();
|
|
532
|
+
if (current) {
|
|
533
|
+
return _CoreManager.default.getUserController().updateUserOnDisk(this);
|
|
534
|
+
}
|
|
535
|
+
return this;
|
|
536
|
+
}
|
|
811
537
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
538
|
+
/**
|
|
539
|
+
* Verify whether a given password is the password of the current user.
|
|
540
|
+
*
|
|
541
|
+
* @param {string} password The password to be verified.
|
|
542
|
+
* @param {object} options The options.
|
|
543
|
+
* @param {boolean} [options.ignoreEmailVerification] Set to `true` to bypass email verification and verify
|
|
544
|
+
* the password regardless of whether the email has been verified. This requires the master key.
|
|
545
|
+
* @returns {Promise} A promise that is fulfilled with a user when the password is correct.
|
|
546
|
+
*/
|
|
547
|
+
verifyPassword(password, options) {
|
|
548
|
+
const username = this.getUsername() || '';
|
|
549
|
+
return ParseUser.verifyPassword(username, password, options);
|
|
550
|
+
}
|
|
551
|
+
static readOnlyAttributes() {
|
|
552
|
+
return ['sessionToken'];
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Adds functionality to the existing Parse.User class.
|
|
557
|
+
*
|
|
558
|
+
* @param {object} protoProps A set of properties to add to the prototype
|
|
559
|
+
* @param {object} classProps A set of static properties to add to the class
|
|
560
|
+
* @static
|
|
561
|
+
* @returns {Parse.User} The newly extended Parse.User class
|
|
562
|
+
*/
|
|
563
|
+
static extend(protoProps, classProps) {
|
|
564
|
+
if (protoProps) {
|
|
565
|
+
for (const prop in protoProps) {
|
|
566
|
+
if (prop !== 'className') {
|
|
567
|
+
(0, _defineProperty.default)(ParseUser.prototype, prop, {
|
|
568
|
+
value: protoProps[prop],
|
|
569
|
+
enumerable: false,
|
|
570
|
+
writable: true,
|
|
571
|
+
configurable: true
|
|
572
|
+
});
|
|
833
573
|
}
|
|
834
574
|
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
}
|
|
575
|
+
}
|
|
576
|
+
if (classProps) {
|
|
577
|
+
for (const prop in classProps) {
|
|
578
|
+
if (prop !== 'className') {
|
|
579
|
+
(0, _defineProperty.default)(ParseUser, prop, {
|
|
580
|
+
value: classProps[prop],
|
|
581
|
+
enumerable: false,
|
|
582
|
+
writable: true,
|
|
583
|
+
configurable: true
|
|
584
|
+
});
|
|
845
585
|
}
|
|
846
586
|
}
|
|
847
|
-
return ParseUser;
|
|
848
587
|
}
|
|
588
|
+
return ParseUser;
|
|
589
|
+
}
|
|
849
590
|
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
if (!canUseCurrentUser) {
|
|
861
|
-
return null;
|
|
862
|
-
}
|
|
863
|
-
var controller = _CoreManager.default.getUserController();
|
|
864
|
-
return controller.currentUser();
|
|
591
|
+
/**
|
|
592
|
+
* Retrieves the currently logged in ParseUser with a valid session,
|
|
593
|
+
* either from memory or localStorage, if necessary.
|
|
594
|
+
*
|
|
595
|
+
* @static
|
|
596
|
+
* @returns {Parse.Object} The currently logged in Parse.User.
|
|
597
|
+
*/
|
|
598
|
+
static current() {
|
|
599
|
+
if (!canUseCurrentUser) {
|
|
600
|
+
return null;
|
|
865
601
|
}
|
|
602
|
+
const controller = _CoreManager.default.getUserController();
|
|
603
|
+
return controller.currentUser();
|
|
604
|
+
}
|
|
866
605
|
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
if (!canUseCurrentUser) {
|
|
878
|
-
return _promise.default.resolve(null);
|
|
879
|
-
}
|
|
880
|
-
var controller = _CoreManager.default.getUserController();
|
|
881
|
-
return controller.currentUserAsync();
|
|
606
|
+
/**
|
|
607
|
+
* Retrieves the currently logged in ParseUser from asynchronous Storage.
|
|
608
|
+
*
|
|
609
|
+
* @static
|
|
610
|
+
* @returns {Promise} A Promise that is resolved with the currently
|
|
611
|
+
* logged in Parse User
|
|
612
|
+
*/
|
|
613
|
+
static currentAsync() {
|
|
614
|
+
if (!canUseCurrentUser) {
|
|
615
|
+
return _promise.default.resolve(null);
|
|
882
616
|
}
|
|
617
|
+
const controller = _CoreManager.default.getUserController();
|
|
618
|
+
return controller.currentUserAsync();
|
|
619
|
+
}
|
|
883
620
|
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
return user.signUp({}, options);
|
|
906
|
-
}
|
|
621
|
+
/**
|
|
622
|
+
* Signs up a new user with a username (or email) and password.
|
|
623
|
+
* This will create a new Parse.User on the server, and also persist the
|
|
624
|
+
* session in localStorage so that you can access the user using
|
|
625
|
+
* {@link #current}.
|
|
626
|
+
*
|
|
627
|
+
* @param {string} username The username (or email) to sign up with.
|
|
628
|
+
* @param {string} password The password to sign up with.
|
|
629
|
+
* @param {object} attrs Extra fields to set on the new user.
|
|
630
|
+
* @param {object} options
|
|
631
|
+
* @static
|
|
632
|
+
* @returns {Promise} A promise that is fulfilled with the user when
|
|
633
|
+
* the signup completes.
|
|
634
|
+
*/
|
|
635
|
+
static signUp(username, password, attrs, options) {
|
|
636
|
+
attrs = attrs || {};
|
|
637
|
+
attrs.username = username;
|
|
638
|
+
attrs.password = password;
|
|
639
|
+
const user = new this(attrs);
|
|
640
|
+
return user.signUp({}, options);
|
|
641
|
+
}
|
|
907
642
|
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
return user.logIn(options);
|
|
934
|
-
}
|
|
643
|
+
/**
|
|
644
|
+
* Logs in a user with a username (or email) and password. On success, this
|
|
645
|
+
* saves the session to disk, so you can retrieve the currently logged in
|
|
646
|
+
* user using <code>current</code>.
|
|
647
|
+
*
|
|
648
|
+
* @param {string} username The username (or email) to log in with.
|
|
649
|
+
* @param {string} password The password to log in with.
|
|
650
|
+
* @param {object} options
|
|
651
|
+
* @static
|
|
652
|
+
* @returns {Promise} A promise that is fulfilled with the user when
|
|
653
|
+
* the login completes.
|
|
654
|
+
*/
|
|
655
|
+
static logIn(username, password, options) {
|
|
656
|
+
if (typeof username !== 'string') {
|
|
657
|
+
return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
|
|
658
|
+
} else if (typeof password !== 'string') {
|
|
659
|
+
return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
|
|
660
|
+
}
|
|
661
|
+
const user = new this();
|
|
662
|
+
user._finishFetch({
|
|
663
|
+
username: username,
|
|
664
|
+
password: password
|
|
665
|
+
});
|
|
666
|
+
return user.logIn(options);
|
|
667
|
+
}
|
|
935
668
|
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
if (typeof username !== 'string') {
|
|
953
|
-
return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
|
|
954
|
-
}
|
|
955
|
-
if (typeof password !== 'string') {
|
|
956
|
-
return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
|
|
957
|
-
}
|
|
958
|
-
if (Object.prototype.toString.call(authData) !== '[object Object]') {
|
|
959
|
-
return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Auth must be an object.'));
|
|
960
|
-
}
|
|
961
|
-
var user = new this();
|
|
962
|
-
user._finishFetch({
|
|
963
|
-
username: username,
|
|
964
|
-
password: password,
|
|
965
|
-
authData: authData
|
|
966
|
-
});
|
|
967
|
-
return user.logIn(options);
|
|
669
|
+
/**
|
|
670
|
+
* Logs in a user with a username (or email) and password, and authData. On success, this
|
|
671
|
+
* saves the session to disk, so you can retrieve the currently logged in
|
|
672
|
+
* user using <code>current</code>.
|
|
673
|
+
*
|
|
674
|
+
* @param {string} username The username (or email) to log in with.
|
|
675
|
+
* @param {string} password The password to log in with.
|
|
676
|
+
* @param {object} authData The authData to log in with.
|
|
677
|
+
* @param {object} options
|
|
678
|
+
* @static
|
|
679
|
+
* @returns {Promise} A promise that is fulfilled with the user when
|
|
680
|
+
* the login completes.
|
|
681
|
+
*/
|
|
682
|
+
static logInWithAdditionalAuth(username, password, authData, options) {
|
|
683
|
+
if (typeof username !== 'string') {
|
|
684
|
+
return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
|
|
968
685
|
}
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
* Logs in a user with an objectId. On success, this saves the session
|
|
972
|
-
* to disk, so you can retrieve the currently logged in user using
|
|
973
|
-
* <code>current</code>.
|
|
974
|
-
*
|
|
975
|
-
* @param {string} userId The objectId for the user.
|
|
976
|
-
* @static
|
|
977
|
-
* @returns {Promise} A promise that is fulfilled with the user when
|
|
978
|
-
* the login completes.
|
|
979
|
-
*/
|
|
980
|
-
}, {
|
|
981
|
-
key: "loginAs",
|
|
982
|
-
value: function (userId /*: string*/) {
|
|
983
|
-
if (!userId) {
|
|
984
|
-
throw new _ParseError.default(_ParseError.default.USERNAME_MISSING, 'Cannot log in as user with an empty user id');
|
|
985
|
-
}
|
|
986
|
-
var controller = _CoreManager.default.getUserController();
|
|
987
|
-
var user = new this();
|
|
988
|
-
return controller.loginAs(user, userId);
|
|
686
|
+
if (typeof password !== 'string') {
|
|
687
|
+
return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
|
|
989
688
|
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
* Logs in a user with a session token. On success, this saves the session
|
|
993
|
-
* to disk, so you can retrieve the currently logged in user using
|
|
994
|
-
* <code>current</code>.
|
|
995
|
-
*
|
|
996
|
-
* @param {string} sessionToken The sessionToken to log in with.
|
|
997
|
-
* @param {object} options
|
|
998
|
-
* @static
|
|
999
|
-
* @returns {Promise} A promise that is fulfilled with the user when
|
|
1000
|
-
* the login completes.
|
|
1001
|
-
*/
|
|
1002
|
-
}, {
|
|
1003
|
-
key: "become",
|
|
1004
|
-
value: function (sessionToken /*: string*/, options /*:: ?: RequestOptions*/) {
|
|
1005
|
-
if (!canUseCurrentUser) {
|
|
1006
|
-
throw new Error('It is not memory-safe to become a user in a server environment');
|
|
1007
|
-
}
|
|
1008
|
-
options = options || {};
|
|
1009
|
-
var becomeOptions /*: RequestOptions*/ = {
|
|
1010
|
-
sessionToken: sessionToken
|
|
1011
|
-
};
|
|
1012
|
-
if (options.hasOwnProperty('useMasterKey')) {
|
|
1013
|
-
becomeOptions.useMasterKey = options.useMasterKey;
|
|
1014
|
-
}
|
|
1015
|
-
var controller = _CoreManager.default.getUserController();
|
|
1016
|
-
var user = new this();
|
|
1017
|
-
return controller.become(user, becomeOptions);
|
|
689
|
+
if (Object.prototype.toString.call(authData) !== '[object Object]') {
|
|
690
|
+
return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Auth must be an object.'));
|
|
1018
691
|
}
|
|
692
|
+
const user = new this();
|
|
693
|
+
user._finishFetch({
|
|
694
|
+
username: username,
|
|
695
|
+
password: password,
|
|
696
|
+
authData
|
|
697
|
+
});
|
|
698
|
+
return user.logIn(options);
|
|
699
|
+
}
|
|
1019
700
|
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
var meOptions /*: RequestOptions*/ = {
|
|
1034
|
-
sessionToken: sessionToken
|
|
1035
|
-
};
|
|
1036
|
-
if (options.useMasterKey) {
|
|
1037
|
-
meOptions.useMasterKey = options.useMasterKey;
|
|
1038
|
-
}
|
|
1039
|
-
var user = new this();
|
|
1040
|
-
return controller.me(user, meOptions);
|
|
701
|
+
/**
|
|
702
|
+
* Logs in a user with an objectId. On success, this saves the session
|
|
703
|
+
* to disk, so you can retrieve the currently logged in user using
|
|
704
|
+
* <code>current</code>.
|
|
705
|
+
*
|
|
706
|
+
* @param {string} userId The objectId for the user.
|
|
707
|
+
* @static
|
|
708
|
+
* @returns {Promise} A promise that is fulfilled with the user when
|
|
709
|
+
* the login completes.
|
|
710
|
+
*/
|
|
711
|
+
static loginAs(userId) {
|
|
712
|
+
if (!userId) {
|
|
713
|
+
throw new _ParseError.default(_ParseError.default.USERNAME_MISSING, 'Cannot log in as user with an empty user id');
|
|
1041
714
|
}
|
|
715
|
+
const controller = _CoreManager.default.getUserController();
|
|
716
|
+
const user = new this();
|
|
717
|
+
return controller.loginAs(user, userId);
|
|
718
|
+
}
|
|
1042
719
|
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
var user = new this();
|
|
1058
|
-
return controller.hydrate(user, userJSON);
|
|
720
|
+
/**
|
|
721
|
+
* Logs in a user with a session token. On success, this saves the session
|
|
722
|
+
* to disk, so you can retrieve the currently logged in user using
|
|
723
|
+
* <code>current</code>.
|
|
724
|
+
*
|
|
725
|
+
* @param {string} sessionToken The sessionToken to log in with.
|
|
726
|
+
* @param {object} options
|
|
727
|
+
* @static
|
|
728
|
+
* @returns {Promise} A promise that is fulfilled with the user when
|
|
729
|
+
* the login completes.
|
|
730
|
+
*/
|
|
731
|
+
static become(sessionToken, options) {
|
|
732
|
+
if (!canUseCurrentUser) {
|
|
733
|
+
throw new Error('It is not memory-safe to become a user in a server environment');
|
|
1059
734
|
}
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
* @param saveOpts
|
|
1067
|
-
* @static
|
|
1068
|
-
* @returns {Promise}
|
|
1069
|
-
*/
|
|
1070
|
-
}, {
|
|
1071
|
-
key: "logInWith",
|
|
1072
|
-
value: function (provider /*: any*/, options /*: { authData?: AuthData }*/, saveOpts /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
|
|
1073
|
-
var user = new this();
|
|
1074
|
-
return user.linkWith(provider, options, saveOpts);
|
|
735
|
+
options = options || {};
|
|
736
|
+
const becomeOptions = {
|
|
737
|
+
sessionToken: sessionToken
|
|
738
|
+
};
|
|
739
|
+
if (options.hasOwnProperty('useMasterKey')) {
|
|
740
|
+
becomeOptions.useMasterKey = options.useMasterKey;
|
|
1075
741
|
}
|
|
742
|
+
const controller = _CoreManager.default.getUserController();
|
|
743
|
+
const user = new this();
|
|
744
|
+
return controller.become(user, becomeOptions);
|
|
745
|
+
}
|
|
1076
746
|
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
747
|
+
/**
|
|
748
|
+
* Retrieves a user with a session token.
|
|
749
|
+
*
|
|
750
|
+
* @param {string} sessionToken The sessionToken to get user with.
|
|
751
|
+
* @param {object} options
|
|
752
|
+
* @static
|
|
753
|
+
* @returns {Promise} A promise that is fulfilled with the user is fetched.
|
|
754
|
+
*/
|
|
755
|
+
static me(sessionToken) {
|
|
756
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
757
|
+
const controller = _CoreManager.default.getUserController();
|
|
758
|
+
const meOptions = {
|
|
759
|
+
sessionToken: sessionToken
|
|
760
|
+
};
|
|
761
|
+
if (options.useMasterKey) {
|
|
762
|
+
meOptions.useMasterKey = options.useMasterKey;
|
|
1093
763
|
}
|
|
764
|
+
const user = new this();
|
|
765
|
+
return controller.me(user, meOptions);
|
|
766
|
+
}
|
|
1094
767
|
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
var requestOptions = {};
|
|
1111
|
-
if (options.hasOwnProperty('useMasterKey')) {
|
|
1112
|
-
requestOptions.useMasterKey = options.useMasterKey;
|
|
1113
|
-
}
|
|
1114
|
-
var controller = _CoreManager.default.getUserController();
|
|
1115
|
-
return controller.requestPasswordReset(email, requestOptions);
|
|
1116
|
-
}
|
|
768
|
+
/**
|
|
769
|
+
* Logs in a user with a session token. On success, this saves the session
|
|
770
|
+
* to disk, so you can retrieve the currently logged in user using
|
|
771
|
+
* <code>current</code>. If there is no session token the user will not logged in.
|
|
772
|
+
*
|
|
773
|
+
* @param {object} userJSON The JSON map of the User's data
|
|
774
|
+
* @static
|
|
775
|
+
* @returns {Promise} A promise that is fulfilled with the user when
|
|
776
|
+
* the login completes.
|
|
777
|
+
*/
|
|
778
|
+
static hydrate(userJSON) {
|
|
779
|
+
const controller = _CoreManager.default.getUserController();
|
|
780
|
+
const user = new this();
|
|
781
|
+
return controller.hydrate(user, userJSON);
|
|
782
|
+
}
|
|
1117
783
|
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
if (options.hasOwnProperty('useMasterKey')) {
|
|
1133
|
-
requestOptions.useMasterKey = options.useMasterKey;
|
|
1134
|
-
}
|
|
1135
|
-
var controller = _CoreManager.default.getUserController();
|
|
1136
|
-
return controller.requestEmailVerification(email, requestOptions);
|
|
1137
|
-
}
|
|
784
|
+
/**
|
|
785
|
+
* Static version of {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
|
|
786
|
+
*
|
|
787
|
+
* @param provider
|
|
788
|
+
* @param options
|
|
789
|
+
* @param {object} [options.authData]
|
|
790
|
+
* @param saveOpts
|
|
791
|
+
* @static
|
|
792
|
+
* @returns {Promise}
|
|
793
|
+
*/
|
|
794
|
+
static logInWith(provider, options, saveOpts) {
|
|
795
|
+
const user = new this();
|
|
796
|
+
return user.linkWith(provider, options, saveOpts);
|
|
797
|
+
}
|
|
1138
798
|
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
799
|
+
/**
|
|
800
|
+
* Logs out the currently logged in user session. This will remove the
|
|
801
|
+
* session from disk, log out of linked services, and future calls to
|
|
802
|
+
* <code>current</code> will return <code>null</code>.
|
|
803
|
+
*
|
|
804
|
+
* @param {object} options
|
|
805
|
+
* @static
|
|
806
|
+
* @returns {Promise} A promise that is resolved when the session is
|
|
807
|
+
* destroyed on the server.
|
|
808
|
+
*/
|
|
809
|
+
static logOut() {
|
|
810
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
811
|
+
const controller = _CoreManager.default.getUserController();
|
|
812
|
+
return controller.logOut(options);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
* Requests a password reset email to be sent to the specified email address
|
|
817
|
+
* associated with the user account. This email allows the user to securely
|
|
818
|
+
* reset their password on the Parse site.
|
|
819
|
+
*
|
|
820
|
+
* @param {string} email The email address associated with the user that
|
|
821
|
+
* forgot their password.
|
|
822
|
+
* @param {object} options
|
|
823
|
+
* @static
|
|
824
|
+
* @returns {Promise}
|
|
825
|
+
*/
|
|
826
|
+
static requestPasswordReset(email, options) {
|
|
827
|
+
options = options || {};
|
|
828
|
+
const requestOptions = {};
|
|
829
|
+
if (options.hasOwnProperty('useMasterKey')) {
|
|
830
|
+
requestOptions.useMasterKey = options.useMasterKey;
|
|
831
|
+
}
|
|
832
|
+
const controller = _CoreManager.default.getUserController();
|
|
833
|
+
return controller.requestPasswordReset(email, requestOptions);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Request an email verification.
|
|
838
|
+
*
|
|
839
|
+
* @param {string} email The email address associated with the user that
|
|
840
|
+
* needs to verify their email.
|
|
841
|
+
* @param {object} options
|
|
842
|
+
* @static
|
|
843
|
+
* @returns {Promise}
|
|
844
|
+
*/
|
|
845
|
+
static requestEmailVerification(email, options) {
|
|
846
|
+
options = options || {};
|
|
847
|
+
const requestOptions = {};
|
|
848
|
+
if (options.hasOwnProperty('useMasterKey')) {
|
|
849
|
+
requestOptions.useMasterKey = options.useMasterKey;
|
|
850
|
+
}
|
|
851
|
+
const controller = _CoreManager.default.getUserController();
|
|
852
|
+
return controller.requestEmailVerification(email, requestOptions);
|
|
853
|
+
}
|
|
1162
854
|
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
855
|
+
/**
|
|
856
|
+
* Verify whether a given password is the password of the current user.
|
|
857
|
+
* @static
|
|
858
|
+
*
|
|
859
|
+
* @param {string} username The username of the user whose password should be verified.
|
|
860
|
+
* @param {string} password The password to be verified.
|
|
861
|
+
* @param {object} options The options.
|
|
862
|
+
* @param {boolean} [options.ignoreEmailVerification] Set to `true` to bypass email verification and verify
|
|
863
|
+
* the password regardless of whether the email has been verified. This requires the master key.
|
|
864
|
+
* @returns {Promise} A promise that is fulfilled with a user when the password is correct.
|
|
865
|
+
*/
|
|
866
|
+
static verifyPassword(username, password, options) {
|
|
867
|
+
if (typeof username !== 'string') {
|
|
868
|
+
return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
|
|
869
|
+
}
|
|
870
|
+
if (typeof password !== 'string') {
|
|
871
|
+
return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
|
|
1176
872
|
}
|
|
873
|
+
const controller = _CoreManager.default.getUserController();
|
|
874
|
+
return controller.verifyPassword(username, password, options || {});
|
|
875
|
+
}
|
|
1177
876
|
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
877
|
+
/**
|
|
878
|
+
* Allow someone to define a custom User class without className
|
|
879
|
+
* being rewritten to _User. The default behavior is to rewrite
|
|
880
|
+
* User to _User for legacy reasons. This allows developers to
|
|
881
|
+
* override that behavior.
|
|
882
|
+
*
|
|
883
|
+
* @param {boolean} isAllowed Whether or not to allow custom User class
|
|
884
|
+
* @static
|
|
885
|
+
*/
|
|
886
|
+
static allowCustomUserClass(isAllowed) {
|
|
887
|
+
_CoreManager.default.set('PERFORM_USER_REWRITE', !isAllowed);
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Allows a legacy application to start using revocable sessions. If the
|
|
892
|
+
* current session token is not revocable, a request will be made for a new,
|
|
893
|
+
* revocable session.
|
|
894
|
+
* It is not necessary to call this method from cloud code unless you are
|
|
895
|
+
* handling user signup or login from the server side. In a cloud code call,
|
|
896
|
+
* this function will not attempt to upgrade the current token.
|
|
897
|
+
*
|
|
898
|
+
* @param {object} options
|
|
899
|
+
* @static
|
|
900
|
+
* @returns {Promise} A promise that is resolved when the process has
|
|
901
|
+
* completed. If a replacement session token is requested, the promise
|
|
902
|
+
* will be resolved after a new token has been fetched.
|
|
903
|
+
*/
|
|
904
|
+
static enableRevocableSession(options) {
|
|
905
|
+
options = options || {};
|
|
906
|
+
_CoreManager.default.set('FORCE_REVOCABLE_SESSION', true);
|
|
907
|
+
if (canUseCurrentUser) {
|
|
908
|
+
const current = ParseUser.current();
|
|
909
|
+
if (current) {
|
|
910
|
+
return current._upgradeToRevocableSession(options);
|
|
1202
911
|
}
|
|
1203
|
-
return _promise.default.resolve();
|
|
1204
912
|
}
|
|
913
|
+
return _promise.default.resolve();
|
|
914
|
+
}
|
|
1205
915
|
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
canUseCurrentUser = true;
|
|
1217
|
-
}
|
|
916
|
+
/**
|
|
917
|
+
* Enables the use of become or the current user in a server
|
|
918
|
+
* environment. These features are disabled by default, since they depend on
|
|
919
|
+
* global objects that are not memory-safe for most servers.
|
|
920
|
+
*
|
|
921
|
+
* @static
|
|
922
|
+
*/
|
|
923
|
+
static enableUnsafeCurrentUser() {
|
|
924
|
+
canUseCurrentUser = true;
|
|
925
|
+
}
|
|
1218
926
|
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
canUseCurrentUser = false;
|
|
1230
|
-
}
|
|
927
|
+
/**
|
|
928
|
+
* Disables the use of become or the current user in any environment.
|
|
929
|
+
* These features are disabled on servers by default, since they depend on
|
|
930
|
+
* global objects that are not memory-safe for most servers.
|
|
931
|
+
*
|
|
932
|
+
* @static
|
|
933
|
+
*/
|
|
934
|
+
static disableUnsafeCurrentUser() {
|
|
935
|
+
canUseCurrentUser = false;
|
|
936
|
+
}
|
|
1231
937
|
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
});
|
|
1254
|
-
}
|
|
938
|
+
/**
|
|
939
|
+
* When registering users with {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} a basic auth provider
|
|
940
|
+
* is automatically created for you.
|
|
941
|
+
*
|
|
942
|
+
* For advanced authentication, you can register an Auth provider to
|
|
943
|
+
* implement custom authentication, deauthentication.
|
|
944
|
+
*
|
|
945
|
+
* @param provider
|
|
946
|
+
* @see {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
|
|
947
|
+
* @see {@link https://docs.parseplatform.org/js/guide/#custom-authentication-module Custom Authentication Module}
|
|
948
|
+
* @static
|
|
949
|
+
*/
|
|
950
|
+
static _registerAuthenticationProvider(provider) {
|
|
951
|
+
authProviders[provider.getAuthType()] = provider;
|
|
952
|
+
// Synchronize the current user with the auth provider.
|
|
953
|
+
ParseUser.currentAsync().then(current => {
|
|
954
|
+
if (current) {
|
|
955
|
+
current._synchronizeAuthData(provider.getAuthType());
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
}
|
|
1255
959
|
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
return ParseUser;
|
|
1283
|
-
}(_ParseObject2.default);
|
|
1284
|
-
_ParseObject2.default.registerSubclass('_User', ParseUser);
|
|
1285
|
-
var DefaultController = {
|
|
1286
|
-
updateUserOnDisk: function (user) {
|
|
1287
|
-
var path = _Storage.default.generatePath(CURRENT_USER_KEY);
|
|
1288
|
-
var json = user.toJSON();
|
|
960
|
+
/**
|
|
961
|
+
* @param provider
|
|
962
|
+
* @param options
|
|
963
|
+
* @param {object} [options.authData]
|
|
964
|
+
* @param saveOpts
|
|
965
|
+
* @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#logInWith logInWith}
|
|
966
|
+
* @static
|
|
967
|
+
* @returns {Promise}
|
|
968
|
+
*/
|
|
969
|
+
static _logInWith(provider, options, saveOpts) {
|
|
970
|
+
const user = new this();
|
|
971
|
+
return user.linkWith(provider, options, saveOpts);
|
|
972
|
+
}
|
|
973
|
+
static _clearCache() {
|
|
974
|
+
currentUserCache = null;
|
|
975
|
+
currentUserCacheMatchesDisk = false;
|
|
976
|
+
}
|
|
977
|
+
static _setCurrentUserCache(user) {
|
|
978
|
+
currentUserCache = user;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
_ParseObject.default.registerSubclass('_User', ParseUser);
|
|
982
|
+
const DefaultController = {
|
|
983
|
+
updateUserOnDisk(user) {
|
|
984
|
+
const path = _Storage.default.generatePath(CURRENT_USER_KEY);
|
|
985
|
+
const json = user.toJSON();
|
|
1289
986
|
delete json.password;
|
|
1290
987
|
json.className = '_User';
|
|
1291
|
-
|
|
988
|
+
let userData = (0, _stringify.default)(json);
|
|
1292
989
|
if (_CoreManager.default.get('ENCRYPTED_USER')) {
|
|
1293
|
-
|
|
990
|
+
const crypto = _CoreManager.default.getCryptoController();
|
|
1294
991
|
userData = crypto.encrypt(json, _CoreManager.default.get('ENCRYPTED_KEY'));
|
|
1295
992
|
}
|
|
1296
|
-
return _Storage.default.setItemAsync(path, userData).then(
|
|
993
|
+
return _Storage.default.setItemAsync(path, userData).then(() => {
|
|
1297
994
|
return user;
|
|
1298
995
|
});
|
|
1299
996
|
},
|
|
1300
|
-
removeUserFromDisk
|
|
1301
|
-
|
|
997
|
+
removeUserFromDisk() {
|
|
998
|
+
const path = _Storage.default.generatePath(CURRENT_USER_KEY);
|
|
1302
999
|
currentUserCacheMatchesDisk = true;
|
|
1303
1000
|
currentUserCache = null;
|
|
1304
1001
|
return _Storage.default.removeItemAsync(path);
|
|
1305
1002
|
},
|
|
1306
|
-
setCurrentUser
|
|
1003
|
+
setCurrentUser(user) {
|
|
1307
1004
|
currentUserCache = user;
|
|
1308
1005
|
user._cleanupAuthData();
|
|
1309
1006
|
user._synchronizeAllAuthData();
|
|
1310
1007
|
return DefaultController.updateUserOnDisk(user);
|
|
1311
1008
|
},
|
|
1312
|
-
currentUser
|
|
1009
|
+
currentUser() {
|
|
1313
1010
|
if (currentUserCache) {
|
|
1314
1011
|
return currentUserCache;
|
|
1315
1012
|
}
|
|
@@ -1319,15 +1016,15 @@ var DefaultController = {
|
|
|
1319
1016
|
if (_Storage.default.async()) {
|
|
1320
1017
|
throw new Error('Cannot call currentUser() when using a platform with an async ' + 'storage system. Call currentUserAsync() instead.');
|
|
1321
1018
|
}
|
|
1322
|
-
|
|
1323
|
-
|
|
1019
|
+
const path = _Storage.default.generatePath(CURRENT_USER_KEY);
|
|
1020
|
+
let userData = _Storage.default.getItem(path);
|
|
1324
1021
|
currentUserCacheMatchesDisk = true;
|
|
1325
1022
|
if (!userData) {
|
|
1326
1023
|
currentUserCache = null;
|
|
1327
1024
|
return null;
|
|
1328
1025
|
}
|
|
1329
1026
|
if (_CoreManager.default.get('ENCRYPTED_USER')) {
|
|
1330
|
-
|
|
1027
|
+
const crypto = _CoreManager.default.getCryptoController();
|
|
1331
1028
|
userData = crypto.decrypt(userData, _CoreManager.default.get('ENCRYPTED_KEY'));
|
|
1332
1029
|
}
|
|
1333
1030
|
userData = JSON.parse(userData);
|
|
@@ -1344,27 +1041,27 @@ var DefaultController = {
|
|
|
1344
1041
|
userData.sessionToken = userData._sessionToken;
|
|
1345
1042
|
delete userData._sessionToken;
|
|
1346
1043
|
}
|
|
1347
|
-
|
|
1044
|
+
const current = _ParseObject.default.fromJSON(userData);
|
|
1348
1045
|
currentUserCache = current;
|
|
1349
1046
|
current._synchronizeAllAuthData();
|
|
1350
1047
|
return current;
|
|
1351
1048
|
},
|
|
1352
|
-
currentUserAsync
|
|
1049
|
+
currentUserAsync() {
|
|
1353
1050
|
if (currentUserCache) {
|
|
1354
1051
|
return _promise.default.resolve(currentUserCache);
|
|
1355
1052
|
}
|
|
1356
1053
|
if (currentUserCacheMatchesDisk) {
|
|
1357
1054
|
return _promise.default.resolve(null);
|
|
1358
1055
|
}
|
|
1359
|
-
|
|
1360
|
-
return _Storage.default.getItemAsync(path).then(
|
|
1056
|
+
const path = _Storage.default.generatePath(CURRENT_USER_KEY);
|
|
1057
|
+
return _Storage.default.getItemAsync(path).then(userData => {
|
|
1361
1058
|
currentUserCacheMatchesDisk = true;
|
|
1362
1059
|
if (!userData) {
|
|
1363
1060
|
currentUserCache = null;
|
|
1364
1061
|
return _promise.default.resolve(null);
|
|
1365
1062
|
}
|
|
1366
1063
|
if (_CoreManager.default.get('ENCRYPTED_USER')) {
|
|
1367
|
-
|
|
1064
|
+
const crypto = _CoreManager.default.getCryptoController();
|
|
1368
1065
|
userData = crypto.decrypt(userData.toString(), _CoreManager.default.get('ENCRYPTED_KEY'));
|
|
1369
1066
|
}
|
|
1370
1067
|
userData = JSON.parse(userData);
|
|
@@ -1381,22 +1078,22 @@ var DefaultController = {
|
|
|
1381
1078
|
userData.sessionToken = userData._sessionToken;
|
|
1382
1079
|
delete userData._sessionToken;
|
|
1383
1080
|
}
|
|
1384
|
-
|
|
1081
|
+
const current = _ParseObject.default.fromJSON(userData);
|
|
1385
1082
|
currentUserCache = current;
|
|
1386
1083
|
current._synchronizeAllAuthData();
|
|
1387
1084
|
return _promise.default.resolve(current);
|
|
1388
1085
|
});
|
|
1389
1086
|
},
|
|
1390
|
-
signUp
|
|
1391
|
-
|
|
1392
|
-
|
|
1087
|
+
signUp(user, attrs, options) {
|
|
1088
|
+
const username = attrs && attrs.username || user.get('username');
|
|
1089
|
+
const password = attrs && attrs.password || user.get('password');
|
|
1393
1090
|
if (!username || !username.length) {
|
|
1394
1091
|
return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty username.'));
|
|
1395
1092
|
}
|
|
1396
1093
|
if (!password || !password.length) {
|
|
1397
1094
|
return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty password.'));
|
|
1398
1095
|
}
|
|
1399
|
-
return user.save(attrs, options).then(
|
|
1096
|
+
return user.save(attrs, options).then(() => {
|
|
1400
1097
|
// Clear the password field
|
|
1401
1098
|
user._finishFetch({
|
|
1402
1099
|
password: undefined
|
|
@@ -1407,15 +1104,15 @@ var DefaultController = {
|
|
|
1407
1104
|
return user;
|
|
1408
1105
|
});
|
|
1409
1106
|
},
|
|
1410
|
-
logIn
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1107
|
+
logIn(user, options) {
|
|
1108
|
+
const RESTController = _CoreManager.default.getRESTController();
|
|
1109
|
+
const stateController = _CoreManager.default.getObjectStateController();
|
|
1110
|
+
const auth = {
|
|
1414
1111
|
username: user.get('username'),
|
|
1415
1112
|
password: user.get('password'),
|
|
1416
1113
|
authData: user.get('authData')
|
|
1417
1114
|
};
|
|
1418
|
-
return RESTController.request(options.usePost ? 'POST' : 'GET', 'login', auth, options).then(
|
|
1115
|
+
return RESTController.request(options.usePost ? 'POST' : 'GET', 'login', auth, options).then(response => {
|
|
1419
1116
|
user._migrateId(response.objectId);
|
|
1420
1117
|
user._setExisted(true);
|
|
1421
1118
|
stateController.setPendingOp(user._getStateIdentifier(), 'username', undefined);
|
|
@@ -1429,13 +1126,13 @@ var DefaultController = {
|
|
|
1429
1126
|
return DefaultController.setCurrentUser(user);
|
|
1430
1127
|
});
|
|
1431
1128
|
},
|
|
1432
|
-
loginAs
|
|
1433
|
-
|
|
1129
|
+
loginAs(user, userId) {
|
|
1130
|
+
const RESTController = _CoreManager.default.getRESTController();
|
|
1434
1131
|
return RESTController.request('POST', 'loginAs', {
|
|
1435
|
-
userId
|
|
1132
|
+
userId
|
|
1436
1133
|
}, {
|
|
1437
1134
|
useMasterKey: true
|
|
1438
|
-
}).then(
|
|
1135
|
+
}).then(response => {
|
|
1439
1136
|
user._finishFetch(response);
|
|
1440
1137
|
user._setExisted(true);
|
|
1441
1138
|
if (!canUseCurrentUser) {
|
|
@@ -1444,15 +1141,15 @@ var DefaultController = {
|
|
|
1444
1141
|
return DefaultController.setCurrentUser(user);
|
|
1445
1142
|
});
|
|
1446
1143
|
},
|
|
1447
|
-
become
|
|
1448
|
-
|
|
1449
|
-
return RESTController.request('GET', 'users/me', {}, options).then(
|
|
1144
|
+
become(user, options) {
|
|
1145
|
+
const RESTController = _CoreManager.default.getRESTController();
|
|
1146
|
+
return RESTController.request('GET', 'users/me', {}, options).then(response => {
|
|
1450
1147
|
user._finishFetch(response);
|
|
1451
1148
|
user._setExisted(true);
|
|
1452
1149
|
return DefaultController.setCurrentUser(user);
|
|
1453
1150
|
});
|
|
1454
1151
|
},
|
|
1455
|
-
hydrate
|
|
1152
|
+
hydrate(user, userJSON) {
|
|
1456
1153
|
user._finishFetch(userJSON);
|
|
1457
1154
|
user._setExisted(true);
|
|
1458
1155
|
if (userJSON.sessionToken && canUseCurrentUser) {
|
|
@@ -1461,26 +1158,26 @@ var DefaultController = {
|
|
|
1461
1158
|
return _promise.default.resolve(user);
|
|
1462
1159
|
}
|
|
1463
1160
|
},
|
|
1464
|
-
me
|
|
1465
|
-
|
|
1466
|
-
return RESTController.request('GET', 'users/me', {}, options).then(
|
|
1161
|
+
me(user, options) {
|
|
1162
|
+
const RESTController = _CoreManager.default.getRESTController();
|
|
1163
|
+
return RESTController.request('GET', 'users/me', {}, options).then(response => {
|
|
1467
1164
|
user._finishFetch(response);
|
|
1468
1165
|
user._setExisted(true);
|
|
1469
1166
|
return user;
|
|
1470
1167
|
});
|
|
1471
1168
|
},
|
|
1472
|
-
logOut
|
|
1473
|
-
|
|
1169
|
+
logOut(options) {
|
|
1170
|
+
const RESTController = _CoreManager.default.getRESTController();
|
|
1474
1171
|
if (options.sessionToken) {
|
|
1475
1172
|
return RESTController.request('POST', 'logout', {}, options);
|
|
1476
1173
|
}
|
|
1477
|
-
return DefaultController.currentUserAsync().then(
|
|
1478
|
-
|
|
1479
|
-
|
|
1174
|
+
return DefaultController.currentUserAsync().then(currentUser => {
|
|
1175
|
+
const path = _Storage.default.generatePath(CURRENT_USER_KEY);
|
|
1176
|
+
let promise = _Storage.default.removeItemAsync(path);
|
|
1480
1177
|
if (currentUser !== null) {
|
|
1481
|
-
|
|
1178
|
+
const currentSession = currentUser.getSessionToken();
|
|
1482
1179
|
if (currentSession && (0, _isRevocableSession.default)(currentSession)) {
|
|
1483
|
-
promise = promise.then(
|
|
1180
|
+
promise = promise.then(() => {
|
|
1484
1181
|
return RESTController.request('POST', 'logout', {}, {
|
|
1485
1182
|
sessionToken: currentSession
|
|
1486
1183
|
});
|
|
@@ -1496,76 +1193,52 @@ var DefaultController = {
|
|
|
1496
1193
|
return promise;
|
|
1497
1194
|
});
|
|
1498
1195
|
},
|
|
1499
|
-
requestPasswordReset
|
|
1500
|
-
|
|
1196
|
+
requestPasswordReset(email, options) {
|
|
1197
|
+
const RESTController = _CoreManager.default.getRESTController();
|
|
1501
1198
|
return RESTController.request('POST', 'requestPasswordReset', {
|
|
1502
1199
|
email: email
|
|
1503
1200
|
}, options);
|
|
1504
1201
|
},
|
|
1505
|
-
upgradeToRevocableSession
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
return
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
return RESTController.request('POST', 'upgradeToRevocableSession', {}, options);
|
|
1522
|
-
case 7:
|
|
1523
|
-
result = _context6.sent;
|
|
1524
|
-
session = new _ParseSession.default();
|
|
1525
|
-
session._finishFetch(result);
|
|
1526
|
-
user._finishFetch({
|
|
1527
|
-
sessionToken: session.getSessionToken()
|
|
1528
|
-
});
|
|
1529
|
-
_context6.next = 13;
|
|
1530
|
-
return user.isCurrentAsync();
|
|
1531
|
-
case 13:
|
|
1532
|
-
current = _context6.sent;
|
|
1533
|
-
if (!current) {
|
|
1534
|
-
_context6.next = 16;
|
|
1535
|
-
break;
|
|
1536
|
-
}
|
|
1537
|
-
return _context6.abrupt("return", DefaultController.setCurrentUser(user));
|
|
1538
|
-
case 16:
|
|
1539
|
-
return _context6.abrupt("return", _promise.default.resolve(user));
|
|
1540
|
-
case 17:
|
|
1541
|
-
case "end":
|
|
1542
|
-
return _context6.stop();
|
|
1543
|
-
}
|
|
1544
|
-
}, _callee6);
|
|
1545
|
-
}))();
|
|
1202
|
+
async upgradeToRevocableSession(user, options) {
|
|
1203
|
+
const token = user.getSessionToken();
|
|
1204
|
+
if (!token) {
|
|
1205
|
+
return _promise.default.reject(new _ParseError.default(_ParseError.default.SESSION_MISSING, 'Cannot upgrade a user with no session token'));
|
|
1206
|
+
}
|
|
1207
|
+
options.sessionToken = token;
|
|
1208
|
+
const RESTController = _CoreManager.default.getRESTController();
|
|
1209
|
+
const result = await RESTController.request('POST', 'upgradeToRevocableSession', {}, options);
|
|
1210
|
+
user._finishFetch({
|
|
1211
|
+
sessionToken: result?.sessionToken || ''
|
|
1212
|
+
});
|
|
1213
|
+
const current = await user.isCurrentAsync();
|
|
1214
|
+
if (current) {
|
|
1215
|
+
return DefaultController.setCurrentUser(user);
|
|
1216
|
+
}
|
|
1217
|
+
return _promise.default.resolve(user);
|
|
1546
1218
|
},
|
|
1547
|
-
linkWith
|
|
1219
|
+
linkWith(user, authData, options) {
|
|
1548
1220
|
return user.save({
|
|
1549
|
-
authData
|
|
1550
|
-
}, options).then(
|
|
1221
|
+
authData
|
|
1222
|
+
}, options).then(() => {
|
|
1551
1223
|
if (canUseCurrentUser) {
|
|
1552
1224
|
return DefaultController.setCurrentUser(user);
|
|
1553
1225
|
}
|
|
1554
1226
|
return user;
|
|
1555
1227
|
});
|
|
1556
1228
|
},
|
|
1557
|
-
verifyPassword
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
username
|
|
1561
|
-
password
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1229
|
+
verifyPassword(username, password, options) {
|
|
1230
|
+
const RESTController = _CoreManager.default.getRESTController();
|
|
1231
|
+
const data = {
|
|
1232
|
+
username,
|
|
1233
|
+
password,
|
|
1234
|
+
...(options.ignoreEmailVerification !== undefined && {
|
|
1235
|
+
ignoreEmailVerification: options.ignoreEmailVerification
|
|
1236
|
+
})
|
|
1237
|
+
};
|
|
1565
1238
|
return RESTController.request('GET', 'verifyPassword', data, options);
|
|
1566
1239
|
},
|
|
1567
|
-
requestEmailVerification
|
|
1568
|
-
|
|
1240
|
+
requestEmailVerification(email, options) {
|
|
1241
|
+
const RESTController = _CoreManager.default.getRESTController();
|
|
1569
1242
|
return RESTController.request('POST', 'verificationEmailRequest', {
|
|
1570
1243
|
email: email
|
|
1571
1244
|
}, options);
|
|
@@ -1573,5 +1246,4 @@ var DefaultController = {
|
|
|
1573
1246
|
};
|
|
1574
1247
|
_CoreManager.default.setParseUser(ParseUser);
|
|
1575
1248
|
_CoreManager.default.setUserController(DefaultController);
|
|
1576
|
-
var _default = ParseUser;
|
|
1577
|
-
exports.default = _default;
|
|
1249
|
+
var _default = exports.default = ParseUser;
|