How can i get the current user in a custome middleware?

Assuming your middleware looks like this:

const mw = (context, next) => {
  ...
};

You can access a user (if one is authenticated) via context.state.user.