@cloudbase/wx-cloud-client-sdk 1.8.1 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -116,11 +116,31 @@ const auth = client.auth;
|
|
|
116
116
|
// 微信小程序 OpenID 静默登录,用户不存在则注册成外部注册用户
|
|
117
117
|
await auth.signInWithOpenId();
|
|
118
118
|
|
|
119
|
+
// 更新用户信息
|
|
120
|
+
const { data, error } = await auth.updateUser({
|
|
121
|
+
nickname: '新昵称',
|
|
122
|
+
gender: 'MALE',
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// 更新 email 或 phone(需要验证)
|
|
126
|
+
const { data, error } = await app.auth.updateUser({
|
|
127
|
+
email: 'new@example.com',
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// 调用 verifyOtp 回调验证
|
|
131
|
+
await data.verifyOtp({ email: 'new@example.com', token: '123456' });
|
|
132
|
+
|
|
133
|
+
// 获取当前用户信息
|
|
134
|
+
const { data, error } = await auth.getUser();
|
|
135
|
+
|
|
119
136
|
// 获取登录状态
|
|
120
|
-
const { data } = auth.getSession();
|
|
137
|
+
const { data, error } = auth.getSession();
|
|
121
138
|
|
|
122
139
|
// 登出
|
|
123
140
|
await auth.signOut();
|
|
141
|
+
|
|
142
|
+
// 刷新登录状态
|
|
143
|
+
await auth.refreshSession();
|
|
124
144
|
```
|
|
125
145
|
|
|
126
146
|
## API
|
|
@@ -134,6 +154,15 @@ await auth.signOut();
|
|
|
134
154
|
| cloud | CloudBaseInstance | 是 | 微信云开发实例 |
|
|
135
155
|
| options.envId | string | 否 | 环境 ID |
|
|
136
156
|
|
|
157
|
+
### 认证方法
|
|
158
|
+
|
|
159
|
+
- `signInWithOpenId()` - 微信小程序 OpenID 静默登录,用户不存在则注册成外部注册用户
|
|
160
|
+
- `updateUser(params)` - 更新用户信息
|
|
161
|
+
- `getUser()` - 获取当前用户信息
|
|
162
|
+
- `getSession()` - 获取登录状态
|
|
163
|
+
- `refreshSession()` - 刷新登录状态
|
|
164
|
+
- `signOut()` - 登出
|
|
165
|
+
|
|
137
166
|
### 数据模型方法
|
|
138
167
|
|
|
139
168
|
- `create(params)` - 创建单条数据
|
package/lib/types/index.d.ts
CHANGED
|
@@ -719,9 +719,11 @@ export type CloudBaseInstance = {
|
|
|
719
719
|
export type IMySqlClient = (options?: IMySqlOptions) => MySqlClient;
|
|
720
720
|
export interface Auth {
|
|
721
721
|
signInWithOpenId: AuthInstance['signInWithOpenId'];
|
|
722
|
+
updateUser: AuthInstance['updateUser'];
|
|
722
723
|
getUser: AuthInstance['getUser'];
|
|
723
724
|
getSession: AuthInstance['getSession'];
|
|
724
725
|
refreshSession: AuthInstance['refreshSession'];
|
|
726
|
+
signOut: AuthInstance['signOut'];
|
|
725
727
|
}
|
|
726
728
|
/**
|
|
727
729
|
* 扩展的云实例接口,扩展了云函数调用接口并包含ORM客户端。
|