mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 12:30:19 +08:00
Add codeToResponse().
This commit is contained in:
@ -25,7 +25,7 @@ import (
|
|||||||
"github.com/casdoor/casdoor/util"
|
"github.com/casdoor/casdoor/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RegisterForm struct {
|
type RequestForm struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
|
||||||
Organization string `json:"organization"`
|
Organization string `json:"organization"`
|
||||||
@ -65,7 +65,7 @@ func (c *ApiController) Register() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var form RegisterForm
|
var form RequestForm
|
||||||
err := json.Unmarshal(c.Ctx.Input.RequestBody, &form)
|
err := json.Unmarshal(c.Ctx.Input.RequestBody, &form)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -33,7 +33,7 @@ func (c *ApiController) HandleLoggedIn(userId string) {
|
|||||||
|
|
||||||
func (c *ApiController) Login() {
|
func (c *ApiController) Login() {
|
||||||
var resp Response
|
var resp Response
|
||||||
var form RegisterForm
|
var form RequestForm
|
||||||
err := json.Unmarshal(c.Ctx.Input.RequestBody, &form)
|
err := json.Unmarshal(c.Ctx.Input.RequestBody, &form)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -69,6 +69,14 @@ func (c *ApiController) DeleteToken() {
|
|||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func codeToResponse(code *object.Code) Response {
|
||||||
|
if code.Code == "" {
|
||||||
|
return Response{Status: "error", Msg: code.Message, Data: code.Code}
|
||||||
|
} else {
|
||||||
|
return Response{Status: "ok", Msg: "success", Data: code.Code}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *ApiController) GetOAuthCode() {
|
func (c *ApiController) GetOAuthCode() {
|
||||||
userId := c.GetSessionUser()
|
userId := c.GetSessionUser()
|
||||||
clientId := c.Input().Get("clientId")
|
clientId := c.Input().Get("clientId")
|
||||||
@ -77,7 +85,8 @@ func (c *ApiController) GetOAuthCode() {
|
|||||||
scope := c.Input().Get("scope")
|
scope := c.Input().Get("scope")
|
||||||
state := c.Input().Get("state")
|
state := c.Input().Get("state")
|
||||||
|
|
||||||
c.Data["json"] = object.GetOAuthCode(userId, clientId, responseType, redirectUri, scope, state)
|
code := object.GetOAuthCode(userId, clientId, responseType, redirectUri, scope, state)
|
||||||
|
c.Data["json"] = codeToResponse(code)
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user