diff --git a/server/api_unlink.go b/server/api_unlink.go index b9ddb99371d98bd4786576851df8abaaee6272b7..00df32d0a400ffeaf661ee27d02eb7bc76c10045 100644 --- a/server/api_unlink.go +++ b/server/api_unlink.go @@ -226,7 +226,7 @@ func (s *ApiServer) UnlinkFacebook(ctx context.Context, in *api.AccountFacebook) } } - err := UnlinkFacebook(ctx, s.logger, s.db, s.socialClient, userID, in.Token) + err := UnlinkFacebook(ctx, s.logger, s.db, s.socialClient, s.config.GetSocial().FacebookLimitedLogin.AppId, userID, in.Token) if err != nil { return nil, err } diff --git a/server/core_unlink.go b/server/core_unlink.go index eae3de8a9b25e0f46aadf1716a15ac5c61e7d19e..0915952915a0fa0b93557015bf215b9f72811c2e 100644 --- a/server/core_unlink.go +++ b/server/core_unlink.go @@ -171,15 +171,18 @@ AND ((apple_id IS NOT NULL return nil } -func UnlinkFacebook(ctx context.Context, logger *zap.Logger, db *sql.DB, socialClient *social.Client, id uuid.UUID, token string) error { +func UnlinkFacebook(ctx context.Context, logger *zap.Logger, db *sql.DB, socialClient *social.Client, appId string, id uuid.UUID, token string) error { if token == "" { return status.Error(codes.InvalidArgument, "Facebook access token is required.") } - facebookProfile, err := socialClient.GetFacebookProfile(ctx, token) + facebookProfile, err := socialClient.CheckFacebookLimitedLoginToken(ctx, appId, token) if err != nil { - logger.Info("Could not authenticate Facebook profile.", zap.Error(err)) - return status.Error(codes.Unauthenticated, "Could not authenticate Facebook profile.") + facebookProfile, err = socialClient.GetFacebookProfile(ctx, token) + if err != nil { + logger.Info("Could not authenticate Facebook profile.", zap.Error(err)) + return status.Error(codes.Unauthenticated, "Could not authenticate Facebook profile.") + } } res, err := db.ExecContext(ctx, `UPDATE users SET facebook_id = NULL, update_time = now() diff --git a/server/runtime_go_nakama.go b/server/runtime_go_nakama.go index c4327363be21f83a505f8977078d99a13f9b27cd..487367ba42775f725de9e525b76214e306c1c2da 100644 --- a/server/runtime_go_nakama.go +++ b/server/runtime_go_nakama.go @@ -617,7 +617,7 @@ func (n *RuntimeGoNakamaModule) UnlinkFacebook(ctx context.Context, userID, toke return errors.New("user ID must be a valid identifier") } - return UnlinkFacebook(ctx, n.logger, n.db, n.socialClient, id, token) + return UnlinkFacebook(ctx, n.logger, n.db, n.socialClient, n.config.GetSocial().FacebookLimitedLogin.AppId, id, token) } func (n *RuntimeGoNakamaModule) UnlinkFacebookInstantGame(ctx context.Context, userID, signedPlayerInfo string) error { diff --git a/server/runtime_javascript_nakama.go b/server/runtime_javascript_nakama.go index 130ba7c4fd674fdf698e6caa852f565d3d398ba3..6aed110c933c12fac0339413abfd6c6874314252 100644 --- a/server/runtime_javascript_nakama.go +++ b/server/runtime_javascript_nakama.go @@ -1969,7 +1969,7 @@ func (n *runtimeJavascriptNakamaModule) unlinkFacebook(r *goja.Runtime) func(goj panic(r.NewTypeError("expects token string")) } - if err := UnlinkFacebook(context.Background(), n.logger, n.db, n.socialClient, id, token); err != nil { + if err := UnlinkFacebook(context.Background(), n.logger, n.db, n.socialClient, n.config.GetSocial().FacebookLimitedLogin.AppId, id, token); err != nil { panic(r.NewGoError(fmt.Errorf("error unlinking: %v", err.Error()))) } diff --git a/server/runtime_lua_nakama.go b/server/runtime_lua_nakama.go index e93b97903dd80e39266f8ed1a107b3028aee25f9..cf8cb547e19d057e16a16e86a8a83c2f63c62711 100644 --- a/server/runtime_lua_nakama.go +++ b/server/runtime_lua_nakama.go @@ -2567,7 +2567,7 @@ func (n *RuntimeLuaNakamaModule) unlinkFacebook(l *lua.LState) int { return 0 } - if err := UnlinkFacebook(l.Context(), n.logger, n.db, n.socialClient, id, token); err != nil { + if err := UnlinkFacebook(l.Context(), n.logger, n.db, n.socialClient, n.config.GetSocial().FacebookLimitedLogin.AppId, id, token); err != nil { l.RaiseError("error unlinking: %v", err.Error()) } return 0