Comments (3)
For now, I've migrated the redirect logic into the existing /auth/signin
page and simplified the flow by having the logic handled entirely in the sign in page, with no server side routes, making it much easier to change the behaviour in future.
The next step is to create /auth/callback
, which should - if the user is logged in - display 'You are being redirected to X' hyperlink (as a fall back for non-JavaScript clients) and (if JavaScript is enabled) update the client side session state immediately and then use Router.push() so that the client is automatically redirected. If the user is not logged in, it should just link (and automatically redirect) to /auth/signin
.
All sign in pages (oauth, email) which currently point to /auth/signin
should then be updated to point to /auth/callback
and the logic in /auth/signin
can be simplified.
Once this is done, we can update the logic so the current path is saved either in the callback URL or in a cookie (we don't want to use localStorage as it's not accessible with 'private browsing' enabled) and then /auth/callback
can be updated to use that value if it is present.
from nextjs-starter.
I've now added a /auth/callback
route and updated all routing rules to send the client there for final routing after signing in (either via oAuth or email), so there is a single home for all the post-sign in routing logic.
from nextjs-starter.
This is now resolved in release 3.5.1.
Users are now sent back to the page they were on once they sign in.
This is done by setting cookie so it works for all providers - including oAuth providers that donβt let you pass URL params and over email, without needing to pass the URL the original email (encrypted or otherwise) and also so it works for clients in private browsing mode (where you can't use localStorage).
Logic in the account page sets the redirect value to /account so that when linking/unlinking oAuth accounts users are sent back to the account page after linking/unlinking.
The behaviour for non-JavaScript clients is somewhat basic. They can still login but are not currently redirected back to the page they came from. Itβs probably not worth the additional work to support this specific feature for users without JavaScript enabled (the site otherwise forks fine for them though - they can still sign in and out and view and update their profile).
Note also that many oAuth service - including Facebook and Google+ - require JavaScript to be enabled to sign in or to link accounts. This is a limitation of those services and there is no workaround for that.
from nextjs-starter.
Related Issues (20)
- Upgrade the deployment settings to now v2 HOT 5
- Authentication.md HOT 1
- Adding CORS HOT 2
- Other CSS Framework
- Can i get res in next-auth.functions ?
- What do i need to pull data from a collection?
- TypeError: Cannot read property 'passport' of undefined on production build HOT 1
- Several dependencies need to be updated HOT 1
- Nodemailer needs to be updated HOT 1
- Update to next.js 9? HOT 3
- build:server & export:server commands are not working
- FullCalendar in Nextjs
- Cloning and installing packages is failing because package-lock.json is present
- npm install fails HOT 2
- Memory leak in app created from this boilerplate
- Sign in doesn't work - takes to page not found '_error' does not exist.
- Deployment to Now v2 HOT 2
- π’ Plans for the future HOT 2
- npm install error - remove package-lock.json before running npm i HOT 1
- π¨ This project is now archived
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nextjs-starter.