Merge branch 'master' into codex/tiaoyitiao
This commit is contained in:
@@ -228,6 +228,8 @@ pub struct WechatBindPhoneRequest {
|
||||
pub code: Option<String>,
|
||||
#[serde(default)]
|
||||
pub wechat_phone_code: Option<String>,
|
||||
#[serde(default)]
|
||||
pub display_name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
@@ -241,6 +243,8 @@ pub struct WechatBindPhoneResponse {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct WechatMiniProgramLoginRequest {
|
||||
pub code: String,
|
||||
#[serde(default)]
|
||||
pub display_name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
@@ -249,6 +253,7 @@ pub struct WechatMiniProgramLoginResponse {
|
||||
pub token: String,
|
||||
pub binding_status: String,
|
||||
pub user: AuthUserPayload,
|
||||
pub created: bool,
|
||||
}
|
||||
|
||||
pub fn build_available_login_methods(
|
||||
@@ -354,6 +359,7 @@ mod tests {
|
||||
phone: None,
|
||||
code: None,
|
||||
wechat_phone_code: Some("wx-phone-code-001".to_string()),
|
||||
display_name: Some("陶泥儿玩家".to_string()),
|
||||
})
|
||||
.expect("payload should serialize");
|
||||
|
||||
@@ -362,8 +368,51 @@ mod tests {
|
||||
json!({
|
||||
"phone": null,
|
||||
"code": null,
|
||||
"wechatPhoneCode": "wx-phone-code-001"
|
||||
"wechatPhoneCode": "wx-phone-code-001",
|
||||
"displayName": "陶泥儿玩家"
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wechat_mini_program_login_request_accepts_native_nickname() {
|
||||
let payload = serde_json::to_value(WechatMiniProgramLoginRequest {
|
||||
code: "wx-mini-code-001".to_string(),
|
||||
display_name: Some("陶泥儿玩家".to_string()),
|
||||
})
|
||||
.expect("payload should serialize");
|
||||
|
||||
assert_eq!(
|
||||
payload,
|
||||
json!({
|
||||
"code": "wx-mini-code-001",
|
||||
"displayName": "陶泥儿玩家"
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wechat_mini_program_login_response_marks_created_user() {
|
||||
let payload = serde_json::to_value(WechatMiniProgramLoginResponse {
|
||||
token: "token-001".to_string(),
|
||||
binding_status: AUTH_BINDING_STATUS_PENDING_BIND_PHONE.to_string(),
|
||||
user: AuthUserPayload {
|
||||
id: "user_001".to_string(),
|
||||
public_user_code: "SY-00000001".to_string(),
|
||||
display_name: "微信旅人".to_string(),
|
||||
avatar_url: None,
|
||||
phone_number: None,
|
||||
phone_number_masked: None,
|
||||
login_method: AUTH_LOGIN_METHOD_WECHAT.to_string(),
|
||||
binding_status: AUTH_BINDING_STATUS_PENDING_BIND_PHONE.to_string(),
|
||||
wechat_bound: true,
|
||||
wechat_display_name: None,
|
||||
wechat_account: Some("wx-openid-001".to_string()),
|
||||
},
|
||||
created: true,
|
||||
})
|
||||
.expect("payload should serialize");
|
||||
|
||||
assert_eq!(payload["created"], serde_json::Value::Bool(true));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user