mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 10:45:47 +08:00
Add CheckUserPassword() API.
This commit is contained in:
parent
8674b4853a
commit
398ba19fa5
@ -185,7 +185,7 @@ func (c *ApiController) Login() {
|
||||
}
|
||||
} else {
|
||||
password := form.Password
|
||||
user, msg = object.CheckUserLogin(form.Organization, form.Username, password)
|
||||
user, msg = object.CheckUserPassword(form.Organization, form.Username, password)
|
||||
}
|
||||
|
||||
if msg != "" {
|
||||
|
@ -231,3 +231,18 @@ func (c *ApiController) SetPassword() {
|
||||
c.Data["json"] = Response{Status: "ok"}
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
func (c *ApiController) CheckUserPassword() {
|
||||
var user object.User
|
||||
err := json.Unmarshal(c.Ctx.Input.RequestBody, &user)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
_, msg := object.CheckUserPassword(user.Owner, user.Name, user.Password)
|
||||
if msg == "" {
|
||||
c.ResponseOk()
|
||||
} else {
|
||||
c.ResponseError(msg)
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ func CheckPassword(user *User, password string) string {
|
||||
}
|
||||
}
|
||||
|
||||
func CheckUserLogin(organization string, username string, password string) (*User, string) {
|
||||
func CheckUserPassword(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"
|
||||
|
@ -83,7 +83,7 @@ func AutoSigninFilter(ctx *context.Context) {
|
||||
password := queryMap.Get("password")
|
||||
if userId != "" && password != "" {
|
||||
owner, name := util.GetOwnerAndNameFromId(userId)
|
||||
_, msg := object.CheckUserLogin(owner, name, password)
|
||||
_, msg := object.CheckUserPassword(owner, name, password)
|
||||
if msg != "" {
|
||||
returnRequest(ctx, msg)
|
||||
return
|
||||
|
@ -61,6 +61,7 @@ func initAPI() {
|
||||
beego.Router("/api/delete-user", &controllers.ApiController{}, "POST:DeleteUser")
|
||||
|
||||
beego.Router("/api/set-password", &controllers.ApiController{}, "POST:SetPassword")
|
||||
beego.Router("/api/check-user-password", &controllers.ApiController{}, "POST:CheckUserPassword")
|
||||
beego.Router("/api/get-email-and-phone", &controllers.ApiController{}, "POST:GetEmailAndPhone")
|
||||
beego.Router("/api/send-verification-code", &controllers.ApiController{}, "POST:SendVerificationCode")
|
||||
beego.Router("/api/reset-email-or-phone", &controllers.ApiController{}, "POST:ResetEmailOrPhone")
|
||||
|
Loading…
x
Reference in New Issue
Block a user