tencent cloud

CloudBase

Product Introduction
Product Overview
Features and Strengths
Use Cases
System Limits
Purchase Guide
Product Pricing
Description Of Billing Capability Items
Yearly/Monthly Subscription Package Description
Alarm and Notification
Overdue Payment Instructions
Development Guide
Cloud Storage
Database
Identity Verification
Cloud function
Static website management
SDK Documentation
Client SDK
Server SDKs
Management-side SDK
Product Agreement
Cloud Development Service Level Agreement

Managing Login Methods

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-12-31 11:48:17

Creating Users

Developers can call the following login methods to sign in or create a user:

Obtaining the Currently Logged In User

You can use the auth.currentUser attribute or the auth.getCurrentUser method to get the currently logged in user. This method will return the user instance of the current logged in user. If the user is not logged in, it will return null:
const app = cloudbase.init({
env: "xxxx-yyy"
})
const auth = app.auth()
// After logging in...
const user = auth.currentUser
// Or
// const user = await auth.getCurrentUser()

Obtaining User Personal Information

You can obtain the user's personal information through various attributes of the user object:
const user = auth.currentUser
let uid, name, gender, created_from
if (user) {
// CloudBase unique user ID
uid = user.uid
// Nickname
name = user.name
// Gender
gender = user.gender
// Creation source
created_from = user.created_from;
}

Updating User Personal Information

You can use the User.update method to update the user's personal information. For example:
const user = auth.currentUser

user
.update({
name: "Tony Stark",
gender: "MALE"
})
.then(() => {
// User information is updated successfully.
});

Refreshing User Information

For a multi-device application, users may update their personal information on one device, and other devices may need to refresh the information:
const user = auth.currentUser;

// Refresh user information.
user.refresh().then(() => {
// After refreshing, the obtained user information will be the latest.
const { username, gender } = user;
});


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백