mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 10:45:47 +08:00
Support Email and phone login.
This commit is contained in:
parent
5b1b8662ac
commit
0f7cd56441
@ -56,9 +56,9 @@ func CheckUserSignup(organization string, username string, password string, disp
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CheckUserLogin(organization string, username string, password string) (*User, string) {
|
func CheckUserLogin(organization string, username string, password string) (*User, string) {
|
||||||
user := GetUserByField(organization, "name", username)
|
user := GetUserByFields(organization, username)
|
||||||
if user == nil {
|
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 {
|
if user.Password != password {
|
||||||
|
@ -146,6 +146,28 @@ func HasUserByField(organizationName string, field string, value string) bool {
|
|||||||
return GetUserByField(organizationName, field, value) != nil
|
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 {
|
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})
|
affected, err := adapter.engine.Table(user).ID(core.PK{user.Owner, user.Name}).Update(map[string]interface{}{field: value})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -178,11 +178,11 @@ class LoginPage extends React.Component {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="username"
|
name="username"
|
||||||
rules={[{ required: true, message: i18next.t("login:Please input your username!") }]}
|
rules={[{ required: true, message: i18next.t("login:Please input your username, Email or phone number!") }]}
|
||||||
>
|
>
|
||||||
<Input
|
<Input
|
||||||
prefix={<UserOutlined className="site-form-item-icon" />}
|
prefix={<UserOutlined className="site-form-item-icon" />}
|
||||||
placeholder={i18next.t("login:username")}
|
placeholder={i18next.t("login:username, Email or phone number")}
|
||||||
disabled={!application.enablePassword}
|
disabled={!application.enablePassword}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
@ -50,8 +50,8 @@
|
|||||||
},
|
},
|
||||||
"login":
|
"login":
|
||||||
{
|
{
|
||||||
"Please input your username!": "Please input your username!",
|
"Please input your username, Email or phone number!": "Please input your username, Email or phone number!",
|
||||||
"username": "username",
|
"username, Email or phone number": "username, Email or phone number",
|
||||||
"Please input your password!": "Please input your password!",
|
"Please input your password!": "Please input your password!",
|
||||||
"password": "password",
|
"password": "password",
|
||||||
"Auto login": "Auto login",
|
"Auto login": "Auto login",
|
||||||
|
@ -50,8 +50,8 @@
|
|||||||
},
|
},
|
||||||
"login":
|
"login":
|
||||||
{
|
{
|
||||||
"Please input your username!": "请输入您的用户名!",
|
"Please input your username, Email or phone number!": "请输入您的用户名、Email或手机号!",
|
||||||
"username": "用户名",
|
"username, Email or phone number": "用户名、Email或手机号",
|
||||||
"Please input your password!": "请输入您的密码!",
|
"Please input your password!": "请输入您的密码!",
|
||||||
"password": "密码",
|
"password": "密码",
|
||||||
"Auto login": "下次自动登录",
|
"Auto login": "下次自动登录",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user