@simpleview/sv-auth-client 4.6.0 → 4.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simpleview/sv-auth-client",
3
- "version": "4.6.0",
3
+ "version": "4.6.1",
4
4
  "description": "Client for communicating with sv-auth",
5
5
  "author": "Owen Allen <owenallenaz@gmail.com>",
6
6
  "dependencies": {
@@ -78,7 +78,7 @@ async function middleware(req, res, next) {
78
78
  const oauth2 = session?.oauth2;
79
79
 
80
80
  // If we don't have a token or a refresh_token than we need to redirect to Auth to log the user in
81
- if (!oauth2) {
81
+ if (!oauth2 || oauth2.type === "initial") {
82
82
  if (req.method !== "GET") {
83
83
  throw new Error("User is not authorized to access this resource.");
84
84
  }
@@ -109,10 +109,6 @@ async function middleware(req, res, next) {
109
109
  return res.redirect(302, loginUrl);
110
110
  }
111
111
 
112
- if (oauth2.type === "initial") {
113
- throw new Error("Invalid session state.");
114
- }
115
-
116
112
  if (oauth2.type === "logged_in") {
117
113
  // If the token is older than 1 day we refresh
118
114
  if (Date.now() - oauth2.token_created > 1000 * 60 * 60 * 24) {