Skip to content

Commit

Permalink
Merge pull request #238 from leancloud/fix/require-phone
Browse files Browse the repository at this point in the history
fix: require phone number when verify sms code
  • Loading branch information
juvenn authored May 11, 2024
2 parents 7143b44 + 1e87c03 commit fb1365d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 28 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,22 @@ on:
jobs:
build:

# Only ubuntu 16.04 has 5.6 and 7.0 preinstalled
runs-on: ubuntu-16.04
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
php-versions: [5.6, 7.0, 7.1, 7.2, 7.3, 7.4]
php-versions: [7.2, 7.4]
name: PHP ${{ matrix.php-versions }} Test
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP Action
uses: shivammathur/[email protected]
with:
php-version: ${{ matrix.php-versions }}
coverage: xdebug

- name: Validate composer.json and composer.lock
run: composer validate --no-check-lock
- name: Get composer cache directory
Expand All @@ -48,7 +47,7 @@ jobs:

- name: Run test suite with phpunit
env:
LEANCLOUD_API_SERVER: https://us.avoscloud.com
LEANCLOUD_API_SERVER: https://wndg0lpt.api.lncldglobal.com
LEANCLOUD_APP_ID: wnDg0lPt0wcYGJSiHRwHBhD4
LEANCLOUD_APP_KEY: u9ekx9HFSFFBErWwyWHFmPDy
LEANCLOUD_APP_MASTER_KEY: ${{ secrets.MASTER_KEY }}
Expand Down
15 changes: 9 additions & 6 deletions src/LeanCloud/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,11 @@ public static function requestPasswordResetBySmsCode($phoneNumber) {
* @param string $smsCode
* @param string $newPassword
*/
public static function resetPasswordBySmsCode($smsCode, $newPassword) {
Client::put("/resetPasswordBySmsCode/{$smsCode}",
array("password" => $newPassword));
public static function resetPasswordBySmsCode($smsCode, $newPassword, $mobilePhoneNumber) {
Client::put("/resetPasswordBySmsCode/{$smsCode}", array(
"password" => $newPassword,
"mobilePhoneNumber" => $mobilePhoneNumber
));
}

/**
Expand All @@ -463,8 +465,10 @@ public static function requestMobilePhoneVerify($phoneNumber) {
*
* @param string $smsCode
*/
public static function verifyMobilePhone($smsCode) {
Client::post("/verifyMobilePhone/{$smsCode}", null);
public static function verifyMobilePhone($smsCode, $mobilePhoneNumber) {
Client::post("/verifyMobilePhone/{$smsCode}", array(
"mobilePhoneNumber" => $mobilePhoneNumber
));
}

/**
Expand Down Expand Up @@ -591,4 +595,3 @@ public function unlinkWith($provider) {
}

}

3 changes: 2 additions & 1 deletion test/AppRouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function testSetRegion() {
}

public function testGetRoute() {
$this->markTestSkipped("app-router no longer available");
$appid = getenv("LEANCLOUD_APP_ID");
$router = AppRouter::getInstance($appid);
$host = $router->getRoute(AppRouter::API_SERVER_KEY);
Expand All @@ -49,4 +50,4 @@ public function testGetRouteWhenAppRouterNotAvailable() {
$host);
}

}
}
16 changes: 3 additions & 13 deletions test/MasterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,16 @@ public function testSaveWithSpecifiedKey() {
$this->assertNotEmpty($file->getObjectId());
$this->assertNotEmpty($file->getName());

$this->assertEquals("abc", $file->getKey());
$this->assertStringEndsWith("abc", $file->getKey());
$url = $file->getUrl();
$parsedUrl = parse_url($url);
$path = $parsedUrl["path"];
$oldSchoolAwsS3FileUrlPrefix = "/avos-cloud-";
$newAwsS3GluttonyUrlPrefix = "https://lc-gluttony";
if (substr($path, 0, strlen($oldSchoolAwsS3FileUrlPrefix)) === $oldSchoolAwsS3FileUrlPrefix) {
$splitPath = explode("/", $path, 3);
$this->assertEquals("abc", $splitPath[2]);
} else if (substr($url, 0, strlen($newAwsS3GluttonyUrlPrefix)) === $newAwsS3GluttonyUrlPrefix) {
$gluttonyPath = "/" + substr(getenv("LEANCLOUD_APP_KEY"), 0, 12) + "/abc";
$this->assertEquals($gluttonyPath, $path);
} else {
$this->assertEquals("/abc", $path);
}
$this->assertStringEndsWith("abc", $path);

$this->assertEquals("text/plain", $file->getMimeType());
$content = file_get_contents($url);
$this->assertEquals("Hello World!", $content);

$file->destroy();
}
}
}
3 changes: 1 addition & 2 deletions test/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function testUpdatePassword() {
public function testVerifyMobilePhone() {
// Ensure the post format is correct
$this->setExpectedException("LeanCloud\CloudException", null, 603);
User::verifyMobilePhone("000000");
User::verifyMobilePhone("000000", "18612340000");
}

public function testSignUpOrLoginByMobilePhone() {
Expand Down Expand Up @@ -308,4 +308,3 @@ public function testFindUserWithSession() {
}

}

0 comments on commit fb1365d

Please sign in to comment.