mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 15:40:12 +01:00
🎨 Support LiuYun account login https://github.com/siyuan-note/siyuan/issues/8578
This commit is contained in:
parent
4459413493
commit
5f13dea7af
2 changed files with 11 additions and 15 deletions
|
|
@ -82,12 +82,8 @@ func deactivateUser(c *gin.Context) {
|
|||
|
||||
func login(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
ret.Code = -1
|
||||
|
||||
arg := map[string]interface{}{}
|
||||
if err := c.BindJSON(&arg); nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = "parses request failed"
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
c.JSON(http.StatusOK, ret)
|
||||
return
|
||||
}
|
||||
|
|
@ -96,10 +92,6 @@ func login(c *gin.Context) {
|
|||
password := arg["userPassword"].(string)
|
||||
captcha := arg["captcha"].(string)
|
||||
cloudRegion := int(arg["cloudRegion"].(float64))
|
||||
result, err := model.Login(name, password, captcha, cloudRegion)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, result)
|
||||
ret = model.Login(name, password, captcha, cloudRegion)
|
||||
c.JSON(http.StatusOK, ret)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -564,21 +564,25 @@ func CheckActivationcode(code string) (retCode int, msg string) {
|
|||
return
|
||||
}
|
||||
|
||||
func Login(userName, password, captcha string, cloudRegion int) (ret *gulu.Result, err error) {
|
||||
func Login(userName, password, captcha string, cloudRegion int) (ret *gulu.Result) {
|
||||
Conf.CloudRegion = cloudRegion
|
||||
Conf.Save()
|
||||
util.CurrentCloudRegion = cloudRegion
|
||||
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest30s()
|
||||
_, err = request.
|
||||
resp, err := request.
|
||||
SetSuccessResult(&result).
|
||||
SetBody(map[string]string{"userName": userName, "userPassword": password, "captcha": captcha}).
|
||||
Post(util.GetCloudServer() + "/apis/siyuan/login")
|
||||
if nil != err {
|
||||
logging.LogErrorf("login failed: %s", err)
|
||||
return nil, errors.New(Conf.Language(18))
|
||||
ret = gulu.Ret.NewResult()
|
||||
ret.Code = -1
|
||||
ret.Msg = Conf.Language(18) + ": " + err.Error()
|
||||
return
|
||||
}
|
||||
logging.LogInfof(resp.Status)
|
||||
ret = &gulu.Result{
|
||||
Code: int(result["code"].(float64)),
|
||||
Msg: result["msg"].(string),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue