mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-02 19:40:19 +08:00
Use c.ResponseError() for all places.
This commit is contained in:
@ -69,19 +69,11 @@ func (c *ApiController) ResponseError(error string, data ...interface{}) {
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
// ResponseErrorWithData ...
|
||||
func (c *ApiController) ResponseErrorWithData(error string, data interface{}) {
|
||||
c.Data["json"] = Response{Status: "error", Msg: error, Data: data}
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
// RequireSignedIn ...
|
||||
func (c *ApiController) RequireSignedIn() (string, bool) {
|
||||
userId := c.GetSessionUsername()
|
||||
if userId == "" {
|
||||
resp := Response{Status: "error", Msg: "Please sign in first"}
|
||||
c.Data["json"] = resp
|
||||
c.ServeJSON()
|
||||
c.ResponseError("Please sign in first")
|
||||
return "", false
|
||||
}
|
||||
return userId, true
|
||||
|
Reference in New Issue
Block a user