Skip to content

Commit 0c35739

Browse files
author
sisishiliu
committed
1.0-beta-2
1 parent 3d3ffef commit 0c35739

16 files changed

Lines changed: 67 additions & 69 deletions

File tree

src/config.sample.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
'loginPluginId' => '105',
1515
'apiPageWidget' => './index.php?action=page.widget',
1616
'apiPageSiteInit' => "./index.php?action=installDB",
17-
'apiSiteLogin' => './index.php?action=api.site.login&body_format=pb',
1817
'session_verify_101' => 'http://open.akaxin.com:5208/index.php?action=api.session.verify&body_format=pb',
19-
'session_verify_102' => './index.php?action=api.session.verify&body_format=pb',
18+
'session_verify_102' => './index.php?action=api.session.verify&body_format=base64pb',
2019
"siteAddress" => '',
2120
'passport_cookie_name' => "duckchat_passport_cookie",
2221
'mail' =>

src/controller/Api/Site/Api_Site_LoginController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cd<?php
1+
<?php
22
/**
33
* Created by PhpStorm.
44
* User: childeYin<尹少爷>
@@ -49,7 +49,6 @@ public function rpc(\Google\Protobuf\Internal\Message $request, \Google\Protobuf
4949
}
5050

5151
$this->ctx->Wpf_Logger->info("api.site.login", "preSessionId=" . $preSessionId);
52-
// $this->ctx->Wpf_Logger->info("api.site.login", " -devicePubkPem=" . $devicePubkPem);
5352

5453
if (!$preSessionId) {
5554
$errorCode = $this->zalyError->errorSiteLogin;
@@ -62,11 +61,11 @@ public function rpc(\Google\Protobuf\Internal\Message $request, \Google\Protobuf
6261
$userProfile = $this->ctx->Site_Login->checkPreSessionIdFromPlatform($preSessionId, $devicePubkPem, 1);
6362

6463
$realSessionId = $userProfile['sessionId'];
64+
6565
$this->ctx->Wpf_Logger->info("api.site.login", "get platform sessionid=" . $realSessionId);
6666

6767
$response = $this->buildApiSiteLoginResponse($userProfile, $realSessionId);
6868

69-
7069
$this->ctx->Wpf_Logger->info("api.site.login", "response=" . $response->serializeToJsonString());
7170

7271
//back to request
@@ -76,7 +75,6 @@ public function rpc(\Google\Protobuf\Internal\Message $request, \Google\Protobuf
7675
$errorCode = $this->zalyError->errorSiteLogin;
7776
$errorInfo = $this->zalyError->getErrorInfo($errorCode);
7877
$this->ctx->Wpf_Logger->error($tag, "=========error=" . $ex->getMessage());
79-
8078
$this->setRpcError($errorCode, $errorInfo);
8179
$this->rpcReturn($transportData->getAction(), new $this->classNameForResponse());
8280
}
@@ -92,9 +90,9 @@ private function buildApiSiteLoginResponse($userInfo, $sessionId)
9290
$publicUserProfile = $this->getPublicUserProfile($userInfo);
9391

9492
if (\Zaly\Proto\Core\UserAvailableType::UserAvailableBlocked == $publicUserProfile->getAvailableType()) {
93+
error_log("user profile failed");
9594
throw new Exception("user is blocked");
9695
}
97-
9896
$allUserProfile = new \Zaly\Proto\Core\AllUserProfile();
9997
$allUserProfile->setPublic($publicUserProfile);
10098

src/controller/BaseController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ public function rpcReturn($action, $response)
112112

113113
$transData->setHeader($this->headers);
114114
$transData->setPackageId($this->requestTransportData->getPackageId());
115-
116115
$body = "";
117116
if ("json" == $this->bodyFormatType) {
118117
$body = $transData->serializeToJsonString();
@@ -126,6 +125,7 @@ public function rpcReturn($action, $response)
126125
return;
127126
}
128127
echo $body;
128+
return;
129129
}
130130

131131
// ignore.~

src/controller/MiniProgram/Passport/MiniProgram_Passport_AccountController.php

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ public function doRequest()
3737
if($method == "post") {
3838

3939
$loginName = $_POST['loginName'];
40-
$newPassword = $_POST['newPassword'];
41-
$oldPassword = $_POST['oldPassword'];
4240

4341
$siteLoginName = $this->loginName;
4442
if($siteLoginName != $loginName) {
@@ -47,14 +45,8 @@ public function doRequest()
4745
echo json_encode(["errCode" => $errorInfo]);
4846
return;
4947
}
50-
if(strlen($newPassword)<5 || strlen($newPassword)>20) {
51-
$errorCode = $this->zalyError->errorPassowrdLength;
52-
$errorInfo = $this->zalyError->getErrorInfo($errorCode);
53-
echo json_encode(["errCode" => $errorInfo]);
54-
return;
55-
}
5648

57-
$this->modifyPassportPassword($loginName, $oldPassword, $newPassword);
49+
$this->modifyPassportPassword($loginName);
5850
echo json_encode(["errCode" => "success"]);
5951
return;
6052
} else {
@@ -69,22 +61,15 @@ public function doRequest()
6961
}
7062
}
7163

72-
private function modifyPassportPassword($loginName, $oldPassword, $newPassword)
64+
private function modifyPassportPassword($loginName)
7365
{
7466
$tag = __CLASS__ . "-". __FUNCTION__;
7567

7668
try{
77-
$modifyPasswordReq = new \Zaly\Proto\Site\ApiPassportPasswordModifyPasswordRequest();
78-
$modifyPasswordReq->setLoginName($loginName);
79-
$modifyPasswordReq->setPassword($oldPassword);
80-
$modifyPasswordReq->setNewPassword($newPassword);
81-
$updatePasswordUrl = "/index.php?action=" . $this->resetPassword . "&body_format=pb";
82-
$updatePasswordUrl = ZalyHelper::getFullReqUrl($updatePasswordUrl);
83-
$this->sendReq( $this->resetPassword, $updatePasswordUrl, $modifyPasswordReq);
8469

8570
$sessionClearRequest = new \Zaly\Proto\Plugin\DuckChatSessionClearRequest();
8671
$sessionClearRequest->setUserId($this->userId);
87-
$sessionClearUrl = "/index.php?action=" . $this->sessionClear . "&body_format=pb&miniProgramId=".$this->passporAccountPluginId;
72+
$sessionClearUrl = "/index.php?action=" . $this->sessionClear . "&body_format=base64pb&miniProgramId=".$this->passporAccountPluginId;
8873
$sessionClearUrl = ZalyHelper::getFullReqUrl($sessionClearUrl);
8974
$this->sendReq($this->sessionClear, $sessionClearUrl, $sessionClearRequest);
9075
}catch (Exception $ex) {
@@ -104,20 +89,16 @@ private function sendReq($action, $url, $dataReq)
10489
$transportData->setAction($action);
10590
$transportData->setHeader(["_".\Zaly\Proto\Core\TransportDataHeaderKey::HeaderUserClientLang => $this->language]);
10691
$data = $transportData->serializeToString();
92+
$data = base64_encode($data);
10793

10894
$pluginProfile = $this->getMiniProgramProfile($this->passporAccountPluginId);
109-
110-
if($action == $this->sessionClear) {
111-
$authKey = $pluginProfile['authKey'];
112-
$data = $this->ctx->ZalyAes->encrypt($data, $authKey);
113-
}
95+
$authKey = $pluginProfile['authKey'];
96+
$data = $this->ctx->ZalyAes->encrypt($data, $authKey);
11497

11598
$result = $this->ctx->ZalyCurl->request("post", $url, $data);
116-
117-
if($action == $this->sessionClear) {
118-
$authKey = $pluginProfile['authKey'];
119-
$result = $this->ctx->ZalyAes->decrypt($data, $authKey);
120-
}
99+
$authKey = $pluginProfile['authKey'];
100+
$result = $this->ctx->ZalyAes->decrypt($result, $authKey);
101+
$result = base64_decode($result);
121102

122103
//解析数据
123104
$transportData = new \Zaly\Proto\Core\TransportData();

src/lib/Util/ZalyHelper.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ public static function getFullReqUrl($reqUrl)
175175
}
176176
if(strpos($reqUrl, "/") == 0) {
177177
$fullUrl = "{$schema}://{$host}{$reqUrl}";
178+
} elseif(strpos($reqUrl, "./") == 0){
179+
$reqUrl = str_replace("./", "/", $reqUrl);
180+
$fullUrl = "{$schema}://{$host}{$reqUrl}";
178181
} else {
179182
$fullUrl = "{$schema}://{$host}/{$reqUrl}";
180183
}

src/model/Site/Site_Login.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public function checkPreSessionIdFromPlatform($preSessionId, $devicePubkPem = ""
4444
//get userProfile from platform
4545
$loginUserProfile = $this->getUserProfileFromPlatform($preSessionId, $sitePriKeyPem);
4646

47-
4847
//get intivation first
4948
$uicInfo = $this->getIntivationCode($loginUserProfile->getInvitationCode());
5049

@@ -91,14 +90,15 @@ private function getUserProfileFromPlatform($preSessionId, $sitePrikPem)
9190
$transportData->setBody($anyBody);
9291
$transportData->setAction($this->sessionVerifyAction);
9392
$data = $transportData->serializeToString();
94-
93+
$data = base64_encode($data);
9594

9695
$pluginIds = $this->ctx->SiteConfigTable->selectSiteConfig(SiteConfig::SITE_LOGIN_PLUGIN_ID);
9796
$pluginId = $pluginIds[SiteConfig::SITE_LOGIN_PLUGIN_ID];
9897
$sessionVerifyUrl = ZalyConfig::getSessionVerifyUrl($pluginId);
9998
$sessionVerifyUrl = ZalyHelper::getFullReqUrl($sessionVerifyUrl);
100-
$this->ctx->Wpf_Logger->error("api.site.login", "get profile from platform url=" . $sessionVerifyUrl);
99+
101100
$result = $this->ctx->ZalyCurl->request("post", $sessionVerifyUrl, $data);
101+
$result = base64_decode($result);
102102

103103
//解析数据
104104
$transportData = new \Zaly\Proto\Core\TransportData();
@@ -122,9 +122,10 @@ private function getUserProfileFromPlatform($preSessionId, $sitePrikPem)
122122
$aesData = $response->getEncryptedProfile();
123123
$randomKey = $this->ctx->ZalyRsa->decrypt($key, $sitePrikPem);
124124
$serialize = $this->ctx->ZalyAes->decrypt($aesData, $randomKey);
125+
125126
//获取LoginUserProfile
126127
$loginUserProfile = unserialize($serialize);
127-
// $this->ctx->Wpf_Logger->error("site: api.session.verify api.site.login", " profile=" . $loginUserProfile->serializeToJsonString());
128+
128129

129130
return $loginUserProfile;
130131
} catch (Exception $ex) {

src/public/css/login.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ body,html {
55
padding:0;
66
margin:0;
77
-webkit-tap-highlight-color: transparent;
8-
background:url("http://duckchat.akaxin.com/border_line.png") no-repeat;
8+
background:url("https://duckchat.akaxin.com/border_line.png") no-repeat;
99
}
1010

1111
.zaly_container {

src/public/css/zaly_msg.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ html, body{
4343
width: 100%;
4444
height: 100%;
4545
font-size: 10.66px;
46-
background: url("http://duckchat.akaxin.com/border_line.png") no-repeat ;
46+
background: url("https://duckchat.akaxin.com/border_line.png") no-repeat ;
4747
}
4848

4949
/**:focus {outline: none;}*/

src/public/css/zaly_widget.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ html, body{
77
width: 100%;
88
height: 100%;
99
font-size: 10.66px;
10-
background:url("http://duckchat.akaxin.com/border_line.png") no-repeat;
10+
background:url("https://duckchat.akaxin.com/border_line.png") no-repeat;
1111
}
1212

1313
.widget {

src/public/js/im/zalyAction.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var ZalyAction = {
4040
api_passport_passwordResetPassword :"site.ApiPassportPasswordResetPasswordRequest",
4141
duckchat_message_send : "plugin.DuckChatMessageSendRequest",
4242
api_passport_passwordUpdateInvitationCode:"site.ApiPassportPasswordUpdateInvitationCodeRequest",
43+
api_passport_passwordModifyPassword : "site.ApiPassportPasswordModifyPasswordRequest",
4344

4445
api_friend_search:"site.ApiFriendSearchRequest",
4546

0 commit comments

Comments
 (0)