mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 10:45:47 +08:00
Add checkPassword().
This commit is contained in:
parent
6e47cd5bd5
commit
6095af0512
@ -55,14 +55,33 @@ func CheckUserSignup(organization string, username string, password string, disp
|
||||
}
|
||||
}
|
||||
|
||||
func checkPassword(user *User, password string) string {
|
||||
if user.PasswordType == "plain" {
|
||||
if password == user.Password {
|
||||
return ""
|
||||
} else {
|
||||
return "password incorrect"
|
||||
}
|
||||
} else if user.PasswordType == "salt" {
|
||||
if getSaltedPassword(password) == user.Password {
|
||||
return ""
|
||||
} else {
|
||||
return "password incorrect"
|
||||
}
|
||||
} else {
|
||||
return fmt.Sprintf("unsupported password type: %s", user.PasswordType)
|
||||
}
|
||||
}
|
||||
|
||||
func CheckUserLogin(organization string, username string, password string) (*User, string) {
|
||||
user := GetUserByFields(organization, username)
|
||||
if user == nil {
|
||||
return nil, "the user does not exist, please sign up first"
|
||||
}
|
||||
|
||||
if user.Password != password {
|
||||
return nil, "password incorrect"
|
||||
msg := checkPassword(user, password)
|
||||
if msg != "" {
|
||||
return nil, msg
|
||||
}
|
||||
|
||||
if user.IsForbidden {
|
||||
|
@ -24,7 +24,6 @@ import * as Setting from "../Setting";
|
||||
import {GithubLoginButton, GoogleLoginButton} from "react-social-login-buttons";
|
||||
import QqLoginButton from "./QqLoginButton";
|
||||
import i18next from "i18next";
|
||||
import {authConfig} from "./Auth";
|
||||
|
||||
class LoginPage extends React.Component {
|
||||
constructor(props) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user