Refactor out c.RequireSignedIn()

This commit is contained in:
Yang Luo
2021-05-17 23:25:28 +08:00
parent 3e41ce0104
commit 947d132362
4 changed files with 32 additions and 30 deletions

View File

@ -25,15 +25,13 @@ type LinkForm struct {
}
func (c *ApiController) Unlink() {
var resp Response
if c.GetSessionUser() == "" {
resp = Response{Status: "error", Msg: "Please sign in first", Data: c.GetSessionUser()}
c.Data["json"] = resp
c.ServeJSON()
userId, ok := c.RequireSignedIn()
if !ok {
return
}
var resp Response
var form LinkForm
err := json.Unmarshal(c.Ctx.Input.RequestBody, &form)
if err != nil {
@ -41,7 +39,6 @@ func (c *ApiController) Unlink() {
}
providerType := form.ProviderType
userId := c.GetSessionUser()
user := object.GetUser(userId)
value := object.GetUserField(user, providerType)