fs-redirect-url

0.0.4 • Public • Published

fs-redirect-url Build Status

Middleware to save the current url in a cookie while the user creates an account to redirect them when they come back afterwards.

##Installation

npm install fs-redirect-url --save

##Usage Set the fs_redirect_url cookie containing the current url before it hits auth middleware in app.js.

  /* app.js */

  var fsRedirectUrl = require('fs-redirect-url');

  // call set function before it gets to auth middleware to set it
  app.useBefore("auth", fsRedirectUrl.set());

  // call unset function after it gets to auth middleware
  app.useAfter("auth", fsRedirectUrl.unset());

If you are just redirecting (like on the homepage) only use the unset function

  /* app.js */

  var fsRedirectUrl = require('fs-redirect-url');

  // this will read the fs_redirect_url cookie if (req.originalUrl !== fs_redirect_url) 
  // and redirect and then clear the cookie or it'll just clear the cookie
  app.useAfter("auth", fsRedirectUrl.unset());

Readme

Keywords

Package Sidebar

Install

npm i fs-redirect-url

Weekly Downloads

1

Version

0.0.4

License

MIT

Last publish

Collaborators

  • tylergraf