Skip to main content

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)

The login module in SDK 2.x removes the loginType concept and no longer exposes types such as ANONYMOUS, WECHAT, CUSTOM, EMAIL, and PHONE.

tip

Description

Deprecated APIs (Attribute)Description
Auth.onLoginStateExpiredAfter logging in, the SDK maintains the login state internally, so developers don't need to care if it's expired.
LoginState.loginTypeDeprecated loginType
LoginState.isAnonymousAuthDeprecated loginType
LoginState.isCustomAuthDeprecated loginType
LoginState.isWeixinAuthDeprecated loginType
LoginState.isUsernameAuthDeprecated loginType
Deprecated API (Attribute)Description
Auth.weixinAuthProviderChange to uniform third-party authorization login API, see API
Auth.customAuthProviderDeprecate customAuthProvider, change to Auth.signInWithCustomTicket
Auth.anonymousAuthProviderDeprecate anonymousAuthProvider, change to Auth.signInAnonymously

Deprecate attribute

API (Attribute)Description
User.loginTypeDeprecated 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.nameUser nickname (case-sensitive from login username User.username)
User.pictureUser-upload avatar
User.phone_numberUser bound mobile number
User.email_verifiedWhether the user has verified their mailbox
User.birthdateUser birthday
User.localeUser set language
User.zoneinfoTime zone
User.providersRefer to UserProfileProvider

UserProfileProvider

FieldDescription
idDefault built-in third-party providerid, wx_open, wx_mp
provider_user_idThird-party provider user id (for example, wxopenid)
nameName

Add new API

APIDescription
Auth.signInLogin API (except anonymous login, third-party login)
Auth.signUpRegistration API
Auth.getVerificationUnified acquisition verification code API (mobile number, mailbox)
Auth.bindPhoneNumberBind/update phone number (original update user information method no longer supported)
Auth.bindEmailBind/update email (original update user information method no longer supported)
Auth.bindWithProviderBind third-party platform (for example WeChat Open/Official Account Platform)
Auth.unbindProviderUnbind third-party platform
Auth.setPasswordSet password
Auth.queryUserQuery user information by condition
Auth.signInWithProviderSign in with third-party platform