mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-09 01:13:41 +08:00
Add checkPassword().
This commit is contained in:
@ -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) {
|
func CheckUserLogin(organization string, username string, password string) (*User, string) {
|
||||||
user := GetUserByFields(organization, username)
|
user := GetUserByFields(organization, username)
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return nil, "the user does not exist, please sign up first"
|
return nil, "the user does not exist, please sign up first"
|
||||||
}
|
}
|
||||||
|
|
||||||
if user.Password != password {
|
msg := checkPassword(user, password)
|
||||||
return nil, "password incorrect"
|
if msg != "" {
|
||||||
|
return nil, msg
|
||||||
}
|
}
|
||||||
|
|
||||||
if user.IsForbidden {
|
if user.IsForbidden {
|
||||||
|
@ -24,7 +24,6 @@ import * as Setting from "../Setting";
|
|||||||
import {GithubLoginButton, GoogleLoginButton} from "react-social-login-buttons";
|
import {GithubLoginButton, GoogleLoginButton} from "react-social-login-buttons";
|
||||||
import QqLoginButton from "./QqLoginButton";
|
import QqLoginButton from "./QqLoginButton";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import {authConfig} from "./Auth";
|
|
||||||
|
|
||||||
class LoginPage extends React.Component {
|
class LoginPage extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
Reference in New Issue
Block a user