Add checkPassword().

This commit is contained in:
Yang Luo 2021-05-03 10:13:32 +08:00
parent 6e47cd5bd5
commit 6095af0512
2 changed files with 21 additions and 3 deletions

View File

@ -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 {

View File

@ -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) {