mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-02 11:20:18 +08:00
Add codeToResponse().
This commit is contained in:
@ -25,7 +25,7 @@ import (
|
||||
"github.com/casdoor/casdoor/util"
|
||||
)
|
||||
|
||||
type RegisterForm struct {
|
||||
type RequestForm struct {
|
||||
Type string `json:"type"`
|
||||
|
||||
Organization string `json:"organization"`
|
||||
@ -65,7 +65,7 @@ func (c *ApiController) Register() {
|
||||
return
|
||||
}
|
||||
|
||||
var form RegisterForm
|
||||
var form RequestForm
|
||||
err := json.Unmarshal(c.Ctx.Input.RequestBody, &form)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -33,7 +33,7 @@ func (c *ApiController) HandleLoggedIn(userId string) {
|
||||
|
||||
func (c *ApiController) Login() {
|
||||
var resp Response
|
||||
var form RegisterForm
|
||||
var form RequestForm
|
||||
err := json.Unmarshal(c.Ctx.Input.RequestBody, &form)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -69,6 +69,14 @@ func (c *ApiController) DeleteToken() {
|
||||
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() {
|
||||
userId := c.GetSessionUser()
|
||||
clientId := c.Input().Get("clientId")
|
||||
@ -77,7 +85,8 @@ func (c *ApiController) GetOAuthCode() {
|
||||
scope := c.Input().Get("scope")
|
||||
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()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user