|
1584 | 1584 | route !== "push" && |
1585 | 1585 | route !== "search/select" && |
1586 | 1586 | route !== "requestPasswordReset" && |
| 1587 | + route !== "requestEmailVerify" && |
| 1588 | + route !== "requestMobilePhoneVerify" && |
| 1589 | + route !== "requestLoginSmsCode" && |
| 1590 | + route !== "verifyMobilePhone" && |
| 1591 | + route !== "requestSmsCode" && |
| 1592 | + route !== "verifySmsCode" && |
1587 | 1593 | route !== "users" && |
1588 | 1594 | route !== "qiniu" && |
1589 | 1595 | route !== "statuses" && |
|
6837 | 6843 | var serverAttrs = model.parse(resp, status, xhr); |
6838 | 6844 | model._finishFetch(serverAttrs); |
6839 | 6845 | model._handleSaveResult(true); |
| 6846 | + if(!serverAttrs.smsCode) |
| 6847 | + delete model.attributes['smsCode']; |
6840 | 6848 | return model; |
6841 | 6849 | })._thenRunCallbacks(options, this); |
6842 | 6850 | }, |
|
6963 | 6971 | return this.get("username"); |
6964 | 6972 | }, |
6965 | 6973 |
|
| 6974 | + /** |
| 6975 | + * Returns get("mobilePhoneNumber"). |
| 6976 | + * @return {String} |
| 6977 | + * @see AV.Object#get |
| 6978 | + */ |
| 6979 | + getMobilePhoneNumber: function(){ |
| 6980 | + return this.get("mobilePhoneNumber"); |
| 6981 | + }, |
| 6982 | + |
| 6983 | + /** |
| 6984 | + * Calls set("mobilePhoneNumber", phoneNumber, options) and returns the result. |
| 6985 | + * @param {String} mobilePhoneNumber |
| 6986 | + * @param {Object} options A Backbone-style options object. |
| 6987 | + * @return {Boolean} |
| 6988 | + * @see AV.Object.set |
| 6989 | + */ |
| 6990 | + setMobilePhoneNumber: function(phone, options) { |
| 6991 | + return this.set("mobilePhoneNumber", phone, options); |
| 6992 | + }, |
| 6993 | + |
6966 | 6994 | /** |
6967 | 6995 | * Calls set("username", username, options) and returns the result. |
6968 | 6996 | * @param {String} username |
|
7078 | 7106 | return user.logIn(options); |
7079 | 7107 | }, |
7080 | 7108 |
|
| 7109 | + /** |
| 7110 | + * Logs in a user with a mobile phone number and sms code sent by |
| 7111 | + * AV.User.requestLoginSmsCode.On success, this |
| 7112 | + * saves the session to disk, so you can retrieve the currently logged in |
| 7113 | + * user using <code>current</code>. |
| 7114 | + * |
| 7115 | + * <p>Calls options.success or options.error on completion.</p> |
| 7116 | + * |
| 7117 | + * @param {String} mobilePhone The user's mobilePhoneNumber |
| 7118 | + * @param {String} smsCode The sms code sent by AV.User.requestLoginSmsCode |
| 7119 | + * @param {Object} options A Backbone-style options object. |
| 7120 | + * @return {AV.Promise} A promise that is fulfilled with the user when |
| 7121 | + * the login completes. |
| 7122 | + * @see AV.User#logIn |
| 7123 | + */ |
| 7124 | + logInWithMobilePhoneSmsCode: function(mobilePhone, smsCode, options){ |
| 7125 | + var user = AV.Object._create("_User"); |
| 7126 | + user._finishFetch({ mobilePhoneNumber: mobilePhone, smsCode: smsCode }); |
| 7127 | + return user.logIn(options); |
| 7128 | + }, |
| 7129 | + |
| 7130 | + /** |
| 7131 | + * Logs in a user with a mobile phone number and password. On success, this |
| 7132 | + * saves the session to disk, so you can retrieve the currently logged in |
| 7133 | + * user using <code>current</code>. |
| 7134 | + * |
| 7135 | + * <p>Calls options.success or options.error on completion.</p> |
| 7136 | + * |
| 7137 | + * @param {String} mobilePhone The user's mobilePhoneNumber |
| 7138 | + * @param {String} password The password to log in with. |
| 7139 | + * @param {Object} options A Backbone-style options object. |
| 7140 | + * @return {AV.Promise} A promise that is fulfilled with the user when |
| 7141 | + * the login completes. |
| 7142 | + * @see AV.User#logIn |
| 7143 | + */ |
| 7144 | + logInWithMobilePhone: function(mobilePhone, password, options){ |
| 7145 | + var user = AV.Object._create("_User"); |
| 7146 | + user._finishFetch({ mobilePhoneNumber: mobilePhone, password: password }); |
| 7147 | + return user.logIn(options); |
| 7148 | + }, |
| 7149 | + |
7081 | 7150 | /** |
7082 | 7151 | * Logs out the currently logged in user session. This will remove the |
7083 | 7152 | * session from disk, log out of linked services, and future calls to |
|
7142 | 7211 | return request._thenRunCallbacks(options); |
7143 | 7212 | }, |
7144 | 7213 |
|
| 7214 | + /** |
| 7215 | + * Requests a verify email to be sent to the specified email address |
| 7216 | + * associated with the user account. This email allows the user to securely |
| 7217 | + * verify their email address on the AV site. |
| 7218 | + * |
| 7219 | + * <p>Calls options.success or options.error on completion.</p> |
| 7220 | + * |
| 7221 | + * @param {String} email The email address associated with the user that |
| 7222 | + * doesn't verify their email address. |
| 7223 | + * @param {Object} options A Backbone-style options object. |
| 7224 | + */ |
| 7225 | + requestEmailVerfiyInBackground: function(email, options) { |
| 7226 | + var json = { email: email }; |
| 7227 | + var request = AV._request("requestEmailVerify", null, null, "POST", |
| 7228 | + json); |
| 7229 | + return request._thenRunCallbacks(options); |
| 7230 | + }, |
| 7231 | + |
| 7232 | + /** |
| 7233 | + * Requests a verify sms code to be sent to the specified mobile phone |
| 7234 | + * number associated with the user account. This sms code allows the user to |
| 7235 | + * verify their mobile phone number by calling AV.User.verifyMobilePhone |
| 7236 | + * |
| 7237 | + * <p>Calls options.success or options.error on completion.</p> |
| 7238 | + * |
| 7239 | + * @param {String} mobilePhone The mobile phone number associated with the |
| 7240 | + * user that doesn't verify their mobile phone number. |
| 7241 | + * @param {Object} options A Backbone-style options object. |
| 7242 | + */ |
| 7243 | + requestMobilePhoneVerify: function(mobilePhone, options){ |
| 7244 | + var json = { mobilePhoneNumber: mobilePhone }; |
| 7245 | + var request = AV._request("requestMobilePhoneVerify", null, null, "POST", |
| 7246 | + json); |
| 7247 | + return request._thenRunCallbacks(options); |
| 7248 | + }, |
| 7249 | + |
| 7250 | + /** |
| 7251 | + * Makes a call to verify sms code that sent by AV.User.Cloud.requestSmsCode |
| 7252 | + * If verify successfully,the user mobilePhoneVerified attribute will be true. |
| 7253 | + * @param {String} code The sms code sent by AV.User.Cloud.requestSmsCode |
| 7254 | + * @param {Object} options A Backbone-style options object |
| 7255 | + * @return {AV.Promise} A promise that will be resolved with the result |
| 7256 | + * of the function. |
| 7257 | + */ |
| 7258 | + verifyMobilePhone: function(code, options){ |
| 7259 | + var request = AV._request("verifyMobilePhone", null, code, "POST", |
| 7260 | + null); |
| 7261 | + return request._thenRunCallbacks(options); |
| 7262 | + }, |
| 7263 | + |
| 7264 | + /** |
| 7265 | + * Requests a logIn sms code to be sent to the specified mobile phone |
| 7266 | + * number associated with the user account. This sms code allows the user to |
| 7267 | + * login by AV.User.logInWithMobilePhoneSmsCode function. |
| 7268 | + * |
| 7269 | + * <p>Calls options.success or options.error on completion.</p> |
| 7270 | + * |
| 7271 | + * @param {String} mobilePhone The mobile phone number associated with the |
| 7272 | + * user that want to login by AV.User.logInWithMobilePhoneSmsCode |
| 7273 | + * @param {Object} options A Backbone-style options object. |
| 7274 | + */ |
| 7275 | + requestLoginSmsCode: function(mobilePhone, options){ |
| 7276 | + var json = { mobilePhoneNumber: mobilePhone }; |
| 7277 | + var request = AV._request("requestLoginSmsCode", null, null, "POST", |
| 7278 | + json); |
| 7279 | + return request._thenRunCallbacks(options); |
| 7280 | + }, |
| 7281 | + |
7145 | 7282 | /** |
7146 | 7283 | * Retrieves the currently logged in AVUser with a valid session, |
7147 | 7284 | * either from memory or localStorage, if necessary. |
|
8658 | 8795 | return request.then(function(resp) { |
8659 | 8796 | return AV._decode(null, resp).result; |
8660 | 8797 | })._thenRunCallbacks(options); |
8661 | | - } |
| 8798 | + }, |
| 8799 | + |
| 8800 | + /** |
| 8801 | + * Makes a call to request a sms code for operation verification. |
| 8802 | + * @param {Object} data The mobile phone number string or a JSON object contains mobilePhoneNumber,op,ttl,name etc. |
| 8803 | + * @param {Object} options A Backbone-style options object |
| 8804 | + * @return {AV.Promise} A promise that will be resolved with the result |
| 8805 | + * of the function. |
| 8806 | + */ |
| 8807 | + requestSmsCode: function(data, options){ |
| 8808 | + if(typeof data === 'string') |
| 8809 | + data = { mobilePhoneNumber: data }; |
| 8810 | + if(!data.mobilePhoneNumber) |
| 8811 | + throw "Missing mobilePhoneNumber."; |
| 8812 | + var request = AV._request("requestSmsCode", null, null, 'POST', |
| 8813 | + data); |
| 8814 | + return request._thenRunCallbacks(options); |
| 8815 | + }, |
| 8816 | + |
| 8817 | + /** |
| 8818 | + * Makes a call to verify sms code that sent by AV.Cloud.requestSmsCode |
| 8819 | + * @param {String} code The sms code sent by AV.Cloud.requestSmsCode |
| 8820 | + * @param {Object} options A Backbone-style options object |
| 8821 | + * @return {AV.Promise} A promise that will be resolved with the result |
| 8822 | + * of the function. |
| 8823 | + */ |
| 8824 | + verifySmsCode: function(code, options){ |
| 8825 | + if(!code) |
| 8826 | + throw "Missing sms code."; |
| 8827 | + var request = AV._request("verifySmsCode", code, null, 'POST', |
| 8828 | + null); |
| 8829 | + return request._thenRunCallbacks(options); |
| 8830 | + }, |
8662 | 8831 | }); |
8663 | 8832 | }(this)); |
8664 | 8833 |
|
|
0 commit comments