123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package sso
- import (
- "fmt"
- "log"
- "syno-common/server/request"
- "time"
- )
- const apiKey = "XVlBzgbaiCMRAjWw"
- const apiSecret = "hTHctcuAxhxKQFDa"
- type BaseResp struct {
- Code int `json:"code"`
- Msg string `json:"msg"`
- Ok bool `json:"ok"`
- Data map[string]interface{} `json:"data"`
- }
- func (r *BaseResp) ToString() string {
- return fmt.Sprintf("{Code: %v,Msg: %v,Ok: %v,Data: %v}", r.Code, r.Msg, r.Ok, r.Data)
- }
- // LoginByAccount
- // 直接向授权中心获取token,无赖之举,syno没有能检查token的接口,起码现在不知道
- func LoginByAccount(account string) BaseResp {
- req := request.NewRequest("http://10.10.0.1:20003", time.Second*10)
- data := map[string]interface{}{
- "user_name": account,
- "app_id": "",
- }
- resp := BaseResp{
- Ok: false,
- Msg: "request fail",
- }
- option := request.Option{
- Url: "/client/login",
- Resp: &resp,
- Accept: "",
- ApiKey: apiKey,
- ApiSecret: apiSecret,
- }
- _, err := req.DoPostJson(data, option)
- if err != nil {
- log.Fatalln(err)
- }
- log.Printf("resp: %v", resp)
- return resp
- }
|