Upgrade from SDK 1.x to 2.x
@cloudbase/js-sdk@2.x compared with 1.x, redesigns the login module, while the usage method of other resource modules (function, database, storage) remains unchanged.
Migration Guide
Comparison of login module between old and new versions (API & property)
LoginType Related
The login module in SDK 2.x removes the loginType concept and no longer exposes types such as ANONYMOUS, WECHAT, CUSTOM, EMAIL, and PHONE.
Description
LoginState Related
| Deprecated APIs (Attribute) | Description |
|---|---|
| Auth.onLoginStateExpired | After logging in, the SDK maintains the login state internally, so developers don't need to care if it's expired. |
| LoginState.loginType | Deprecated loginType |
| LoginState.isAnonymousAuth | Deprecated loginType |
| LoginState.isCustomAuth | Deprecated loginType |
| LoginState.isWeixinAuth | Deprecated loginType |
| LoginState.isUsernameAuth | Deprecated loginType |
AuthProvider Related
| Deprecated API (Attribute) | Description |
|---|---|
| Auth.weixinAuthProvider | Change to uniform third-party authorization login API, see API |
| Auth.customAuthProvider | Deprecate customAuthProvider, change to Auth.signInWithCustomTicket |
| Auth.anonymousAuthProvider | Deprecate anonymousAuthProvider, change to Auth.signInAnonymously |
User related
Deprecate attribute
| API (Attribute) | Description |
|---|---|
| User.loginType | Deprecated loginType |
Deprecate User.openid. Refer to the new attribute User.providers. Deprecate User.wxOpenId. Refer to the new attribute User.providers. Deprecate User.wxPublicId. Refer to the new attribute User.providers. Deprecate User.qqMiniOpenId. Refer to the new attribute User.providers. Deprecate User.customUserId. Use User.uid as the unique user ID. Deprecate User.nickName. Use the new attribute User.name for nickname. Deprecate User.avatarUrl. Use the new attribute User.picture for avatar. Deprecate User.hasPassword. Deprecate User.location. Deprecate User.linkWithTicket. Currently, the custom login userId matches the cloud development uid, with no need for association operations. Deprecate User.linkWithRedirect. Use the new API Auth.bindWithProvider. Deprecate User.linkWithPhoneNumber. Use the new API Auth.bindPhoneNumber. Deprecate User.updateEmail. Use the new API Auth.bindEmail. Deprecate User.updatePhoneNumber. Use the new API Auth.bindPhoneNumber.
new attribute
| API (Attribute) | Description |
|---|---|
| User.name | User nickname (case-sensitive from login username User.username) |
| User.picture | User-upload avatar |
| User.phone_number | User bound mobile number |
| User.email_verified | Whether the user has verified their mailbox |
| User.birthdate | User birthday |
| User.locale | User set language |
| User.zoneinfo | Time zone |
| User.providers | Refer to UserProfileProvider |
UserProfileProvider
| Field | Description |
|---|---|
| id | Default built-in third-party providerid, wx_open, wx_mp |
| provider_user_id | Third-party provider user id (for example, wxopenid) |
| name | Name |
Auth API Related
Add new API
| API | Description |
|---|---|
| Auth.signIn | Login API (except anonymous login, third-party login) |
| Auth.signUp | Registration API |
| Auth.getVerification | Unified acquisition verification code API (mobile number, mailbox) |
| Auth.bindPhoneNumber | Bind/update phone number (original update user information method no longer supported) |
| Auth.bindEmail | Bind/update email (original update user information method no longer supported) |
| Auth.bindWithProvider | Bind third-party platform (for example WeChat Open/Official Account Platform) |
| Auth.unbindProvider | Unbind third-party platform |
| Auth.setPassword | Set password |
| Auth.queryUser | Query user information by condition |
| Auth.signInWithProvider | Sign in with third-party platform |