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()
user object:const user = auth.currentUserlet uid, name, gender, created_fromif (user) {// CloudBase unique user IDuid = user.uid// Nicknamename = user.name// Gendergender = user.gender// Creation sourcecreated_from = user.created_from;}
User.update method to update the user's personal information. For example:const user = auth.currentUseruser.update({name: "Tony Stark",gender: "MALE"}).then(() => {// User information is updated successfully.});
const user = auth.currentUser;// Refresh user information.user.refresh().then(() => {// After refreshing, the obtained user information will be the latest.const { username, gender } = user;});
Feedback