amplify icon indicating copy to clipboard operation
amplify copied to clipboard

middleware for issue 617

Open KonnyGuo opened this issue 2 years ago • 1 comments

Created middleware folder in amplify/server Created auth.js file in amplify/server/middleware

3 functions

  • ensureAuthenticated to check if user is login/authenticated. If not redirect them to some login page
  • ensureAdmin to check if user is login and is an admin. If not redirect to some login page
  • ensureGuest to check user is not login/authenticated. If they are redirect them to some dashboard/profile

Areas that need work/review

  • The redirect endpoints need to be updated accordingly
  • ensureAdmin function won't work until some admin data is created in the DB. Logic will need to be updated.

To use require the middleware like below const { ensureAuth, ensureGuest, ensureAdmin } = require("../middleware/auth"); Router.get("some endpoint", choose a middleware here(ensureAuth, ensureGuest, ensureGuest), {rest of code logic}))

KonnyGuo avatar Oct 28 '23 00:10 KonnyGuo

Hello there, thanks for opening your first Pull Request. Someone will review it soon.

github-actions[bot] avatar Oct 28 '23 00:10 github-actions[bot]