GetUserInfo provider specific call to get userinfomation
(r *http.Request, user *structs.User, customClaims *structs.CustomClaims, ptokens *structs.PTokens, opts ...oauth2.AuthCodeOption)
| 35 | |
| 36 | // GetUserInfo provider specific call to get userinfomation |
| 37 | func (Provider) GetUserInfo(r *http.Request, user *structs.User, customClaims *structs.CustomClaims, ptokens *structs.PTokens, opts ...oauth2.AuthCodeOption) (rerr error) { |
| 38 | client, _, err := common.PrepareTokensAndClient(r, ptokens, true) |
| 39 | if err != nil { |
| 40 | return err |
| 41 | } |
| 42 | userinfo, err := client.Get(cfg.GenOAuth.UserInfoURL) |
| 43 | if err != nil { |
| 44 | return err |
| 45 | } |
| 46 | defer func() { |
| 47 | if err := userinfo.Body.Close(); err != nil { |
| 48 | rerr = err |
| 49 | } |
| 50 | }() |
| 51 | data, _ := io.ReadAll(userinfo.Body) |
| 52 | log.Infof("Ocs userinfo body: %s", string(data)) |
| 53 | if err = common.MapClaims(data, customClaims); err != nil { |
| 54 | log.Error(err) |
| 55 | return err |
| 56 | } |
| 57 | ncUser := structs.NextcloudUser{} |
| 58 | if err = json.Unmarshal(data, &ncUser); err != nil { |
| 59 | log.Error(err) |
| 60 | return err |
| 61 | } |
| 62 | ncUser.PrepareUserData() |
| 63 | user.Username = ncUser.Username |
| 64 | user.Email = ncUser.Email |
| 65 | return nil |
| 66 | } |
nothing calls this directly
no test coverage detected