Rootquotient interview question

Write a middleware to authenticate a user and how do you use it