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) {
|
func login(c *gin.Context) {
|
||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
ret.Code = -1
|
arg, ok := util.JsonArg(c, ret)
|
||||||
|
if !ok {
|
||||||
arg := map[string]interface{}{}
|
|
||||||
if err := c.BindJSON(&arg); nil != err {
|
|
||||||
ret.Code = -1
|
|
||||||
ret.Msg = "parses request failed"
|
|
||||||
c.JSON(http.StatusOK, ret)
|
c.JSON(http.StatusOK, ret)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -96,10 +92,6 @@ func login(c *gin.Context) {
|
||||||
password := arg["userPassword"].(string)
|
password := arg["userPassword"].(string)
|
||||||
captcha := arg["captcha"].(string)
|
captcha := arg["captcha"].(string)
|
||||||
cloudRegion := int(arg["cloudRegion"].(float64))
|
cloudRegion := int(arg["cloudRegion"].(float64))
|
||||||
result, err := model.Login(name, password, captcha, cloudRegion)
|
ret = model.Login(name, password, captcha, cloudRegion)
|
||||||
if nil != err {
|
c.JSON(http.StatusOK, ret)
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, result)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -564,21 +564,25 @@ func CheckActivationcode(code string) (retCode int, msg string) {
|
||||||
return
|
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.CloudRegion = cloudRegion
|
||||||
Conf.Save()
|
Conf.Save()
|
||||||
util.CurrentCloudRegion = cloudRegion
|
util.CurrentCloudRegion = cloudRegion
|
||||||
|
|
||||||
result := map[string]interface{}{}
|
result := map[string]interface{}{}
|
||||||
request := httpclient.NewCloudRequest30s()
|
request := httpclient.NewCloudRequest30s()
|
||||||
_, err = request.
|
resp, err := request.
|
||||||
SetSuccessResult(&result).
|
SetSuccessResult(&result).
|
||||||
SetBody(map[string]string{"userName": userName, "userPassword": password, "captcha": captcha}).
|
SetBody(map[string]string{"userName": userName, "userPassword": password, "captcha": captcha}).
|
||||||
Post(util.GetCloudServer() + "/apis/siyuan/login")
|
Post(util.GetCloudServer() + "/apis/siyuan/login")
|
||||||
if nil != err {
|
if nil != err {
|
||||||
logging.LogErrorf("login failed: %s", 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{
|
ret = &gulu.Result{
|
||||||
Code: int(result["code"].(float64)),
|
Code: int(result["code"].(float64)),
|
||||||
Msg: result["msg"].(string),
|
Msg: result["msg"].(string),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue