AfterSave ACL stopped working after upgrade to 3.x

I’ve been using the following for modification of users after registration for years, however the following function is no longer working. All the usual 3.x updates have worked however this one is pretty dangerous as it gives Public Read which isn’t ideal!

  async afterSave(request) {
    const user = request.object;

    if (!request.object.existed()) {
      var acl = new Parse.ACL(user);
      acl.setReadAccess(user, true);
      acl.setWriteAccess(user, true);
      user.setACL(acl);

      const user = await user.save(null, { useMasterKey: true });
      const query = new Parse.Query(Parse.Role).equalTo('name', 'user');
      const userRole = await query.first({ useMasterKey: true });

      if (userRole) {
        userRole.getUsers().add(user);
        return userRole.save(null, { useMasterKey: true });
      } else {
        throw new Error('Cannot find user role');
      }
    }
  }

Please define “no longer working”: is it not called? Does it raise an error?

This is my stupidity. Notice the reassignment of the user variable when attempting the async save…

That was the issue - thanks for replying.