From a65bba029812def069f500273c7c846b6f744447 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Tue, 16 Nov 2021 17:07:41 +0800 Subject: [PATCH 1/2] fix: username is required when creating a new user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thank 沉寂 for bringing this to our attention. --- leancloud/users.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/leancloud/users.go b/leancloud/users.go index d8c95f5..d359431 100644 --- a/leancloud/users.go +++ b/leancloud/users.go @@ -130,7 +130,9 @@ func (ref *Users) SignUpByMobilePhone(number, smsCode string) (*User, error) { func (ref *Users) SignUpByEmail(email, password string) (*User, error) { body := map[string]string{ - "email": email, + "email": email, + // username & password fields are required for all users + "username": email, "password": password, } decodedUser, err := objectCreate(ref, body) From 877e9371cd4a2b9ab7560b748f9f142cc4497812 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Tue, 16 Nov 2021 17:17:43 +0800 Subject: [PATCH 2/2] feat: Remove SignUpByEmail to be consistent with other SDKs. This method did not work before so the removal does not introduce a breaking change. --- leancloud/users.go | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/leancloud/users.go b/leancloud/users.go index d359431..f4c4a67 100644 --- a/leancloud/users.go +++ b/leancloud/users.go @@ -128,26 +128,6 @@ func (ref *Users) SignUpByMobilePhone(number, smsCode string) (*User, error) { return decodedUser, nil } -func (ref *Users) SignUpByEmail(email, password string) (*User, error) { - body := map[string]string{ - "email": email, - // username & password fields are required for all users - "username": email, - "password": password, - } - decodedUser, err := objectCreate(ref, body) - if err != nil { - return nil, err - } - - user, ok := decodedUser.(*User) - if !ok { - return nil, fmt.Errorf("unexpected error when parse User from response: want type *User but %v", reflect.TypeOf(decodedUser)) - } - - return user, nil -} - func (ref *Users) ResetPasswordBySMSCode(number, smsCode, password string, authOptions ...AuthOption) error { path := "/1.1/resetPasswordBySmsCode/" options := ref.c.getRequestOptions()