diff --git a/object/check.go b/object/check.go index ef710ff3..92fe16f6 100644 --- a/object/check.go +++ b/object/check.go @@ -56,9 +56,9 @@ func CheckUserSignup(organization string, username string, password string, disp } func CheckUserLogin(organization string, username string, password string) (*User, string) { - user := GetUserByField(organization, "name", username) + user := GetUserByFields(organization, username) if user == nil { - return nil, "username does not exist, please sign up first" + return nil, "the user does not exist, please sign up first" } if user.Password != password { diff --git a/object/user.go b/object/user.go index d7c7b693..cbeb4ecb 100644 --- a/object/user.go +++ b/object/user.go @@ -146,6 +146,28 @@ func HasUserByField(organizationName string, field string, value string) bool { return GetUserByField(organizationName, field, value) != nil } +func GetUserByFields(organization string, field string) *User { + // check username + user := GetUserByField(organization, "name", field) + if user != nil { + return user + } + + // check email + user = GetUserByField(organization, "email", field) + if user != nil { + return user + } + + // check phone + user = GetUserByField(organization, "phone", field) + if user != nil { + return user + } + + return nil +} + func SetUserField(user *User, field string, value string) bool { affected, err := adapter.engine.Table(user).ID(core.PK{user.Owner, user.Name}).Update(map[string]interface{}{field: value}) if err != nil { diff --git a/web/src/auth/LoginPage.js b/web/src/auth/LoginPage.js index a0aee597..5410ca76 100644 --- a/web/src/auth/LoginPage.js +++ b/web/src/auth/LoginPage.js @@ -178,11 +178,11 @@ class LoginPage extends React.Component { } - placeholder={i18next.t("login:username")} + placeholder={i18next.t("login:username, Email or phone number")} disabled={!application.enablePassword} /> diff --git a/web/src/locales/en.json b/web/src/locales/en.json index 9b2e82e9..9fd06055 100644 --- a/web/src/locales/en.json +++ b/web/src/locales/en.json @@ -50,8 +50,8 @@ }, "login": { - "Please input your username!": "Please input your username!", - "username": "username", + "Please input your username, Email or phone number!": "Please input your username, Email or phone number!", + "username, Email or phone number": "username, Email or phone number", "Please input your password!": "Please input your password!", "password": "password", "Auto login": "Auto login", diff --git a/web/src/locales/zh.json b/web/src/locales/zh.json index 18fcca4f..900379a7 100644 --- a/web/src/locales/zh.json +++ b/web/src/locales/zh.json @@ -50,8 +50,8 @@ }, "login": { - "Please input your username!": "请输入您的用户名!", - "username": "用户名", + "Please input your username, Email or phone number!": "请输入您的用户名、Email或手机号!", + "username, Email or phone number": "用户名、Email或手机号", "Please input your password!": "请输入您的密码!", "password": "密码", "Auto login": "下次自动登录",