Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ php:
- 7.2

env:
- LEANCLOUD_API_SERVER="https://us-api.leancloud.cn" LEANCLOUD_APP_ID=wnDg0lPt0wcYGJSiHRwHBhD4 LEANCLOUD_APP_KEY=u9ekx9HFSFFBErWwyWHFmPDy LEANCLOUD_REGION=US LEANCLOUD_APP_HOST="127.0.0.1" LEANCLOUD_APP_PORT=8081 LEANCLOUD_WILDCARD_DOMAIN="lncldglobal.com"
- LEANCLOUD_API_SERVER="https://us.avoscloud.com" LEANCLOUD_APP_ID=wnDg0lPt0wcYGJSiHRwHBhD4 LEANCLOUD_APP_KEY=u9ekx9HFSFFBErWwyWHFmPDy LEANCLOUD_REGION=US LEANCLOUD_APP_HOST="127.0.0.1" LEANCLOUD_APP_PORT=8081 LEANCLOUD_WILDCARD_DOMAIN="lncldglobal.com"

install:
- composer install
Expand Down
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

0.10.0 发布日期:2019-06-24
----

- 添加 `User::signUpOrLoginByMobilePhone` 支持手机注册或登录

0.9.0 发布日期:2019-05-23
----

Expand Down
2 changes: 1 addition & 1 deletion src/LeanCloud/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Client {
/**
* Client version
*/
const VERSION = '0.9.0';
const VERSION = '0.10.0';

/**
* API Version string
Expand Down
16 changes: 15 additions & 1 deletion src/LeanCloud/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,21 @@ public static function verifyMobilePhone($smsCode) {
Client::post("/verifyMobilePhone/{$smsCode}", null);
}


/**
* Sign up user by mobile phone and SMS code
*
* @param string $phoneNumber
* @param string $smsCode
*/
public static function signUpOrLoginByMobilePhone($phoneNumber, $smsCode) {
$resp = Client::post("/usersByMobilePhone", array(
"mobilePhoneNumber" => $phoneNumber,
"smsCode" => $smsCode
));
$user = new static();
$user->mergeAfterFetch($data);
User::saveCurrentUser($user);
}

/*
* Link and unlink with 3rd party auth provider
Expand Down
6 changes: 6 additions & 0 deletions test/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ public function testVerifyMobilePhone() {
User::verifyMobilePhone("000000");
}

public function testSignUpOrLoginByMobilePhone() {
// Ensure the post format is correct
$this->setExpectedException("LeanCloud\CloudException", null, 603);
User::signUpOrLoginByMobilePhone("18612340000", "000000");
}

public function testLogInWithLinkedService() {
$user = User::logIn("alice", "blabla");

Expand Down