@pga/auth-flow-provider
Advanced tools
Comparing version 1.1.1 to 1.3.0
@@ -6,10 +6,13 @@ # Change Log | ||
<a name="1.1.1"></a> | ||
## [1.1.1](https://github.com/pgahq/pga-common/compare/@pga/auth-flow-provider@0.0.5...@pga/auth-flow-provider@1.1.1) (2024-02-16) | ||
<a name="1.3.0"></a> | ||
# [1.3.0](https://github.com/pgahq/pga-common/compare/@pga/auth-flow-provider@0.0.5...@pga/auth-flow-provider@1.3.0) (2024-03-13) | ||
### Features | ||
* **auth-flow-provider:** added RedirectToSignup and redirectToSignup to auth0 implementation ([d336225](https://github.com/pgahq/pga-common/commit/d336225)) | ||
**Note:** Version bump only for package @pga/auth-flow-provider | ||
<a name="0.0.5"></a> | ||
@@ -16,0 +19,0 @@ ## [0.0.5](https://github.com/pgahq/pga-common/compare/@pga/auth-flow-provider@0.0.3...@pga/auth-flow-provider@0.0.5) (2019-06-19) |
@@ -19,3 +19,3 @@ (function (global, factory) { | ||
}); | ||
exports.getToken = exports.withAuthProvider = exports.redirectToLogout = exports.RedirectToLogout = exports.redirectToLogin = exports.RedirectToLogin = exports.PrivateRouteGatsby = exports.PrivateRoute = exports.AuthFlowProvider = undefined; | ||
exports.getToken = exports.withAuthProvider = exports.redirectToSignup = exports.RedirectToSignup = exports.redirectToLogout = exports.RedirectToLogout = exports.redirectToLogin = exports.RedirectToLogin = exports.PrivateRouteGatsby = exports.PrivateRoute = exports.AuthFlowProvider = undefined; | ||
@@ -45,4 +45,6 @@ var _AuthFlowProvider2 = _interopRequireDefault(_AuthFlowProvider); | ||
exports.redirectToLogout = _RedirectToLogout.redirectToLogout; | ||
exports.RedirectToSignup = _RedirectToLogin.RedirectToSignup; | ||
exports.redirectToSignup = _RedirectToLogin.redirectToSignup; | ||
exports.withAuthProvider = _withAuthProvider2.default; | ||
exports.getToken = _token.getToken; | ||
}); |
(function (global, factory) { | ||
if (typeof define === "function" && define.amd) { | ||
define(['exports', 'babel-runtime/regenerator', 'babel-runtime/helpers/asyncToGenerator', 'react', './client'], factory); | ||
define(['exports', 'babel-runtime/regenerator', 'babel-runtime/helpers/extends', 'babel-runtime/helpers/asyncToGenerator', 'react', './client'], factory); | ||
} else if (typeof exports !== "undefined") { | ||
factory(exports, require('babel-runtime/regenerator'), require('babel-runtime/helpers/asyncToGenerator'), require('react'), require('./client')); | ||
factory(exports, require('babel-runtime/regenerator'), require('babel-runtime/helpers/extends'), require('babel-runtime/helpers/asyncToGenerator'), require('react'), require('./client')); | ||
} else { | ||
@@ -10,6 +10,6 @@ var mod = { | ||
}; | ||
factory(mod.exports, global.regenerator, global.asyncToGenerator, global.react, global.client); | ||
factory(mod.exports, global.regenerator, global._extends, global.asyncToGenerator, global.react, global.client); | ||
global.RedirectToLogin = mod.exports; | ||
} | ||
})(this, function (exports, _regenerator, _asyncToGenerator2, _react, _client) { | ||
})(this, function (exports, _regenerator, _extends2, _asyncToGenerator2, _react, _client) { | ||
'use strict'; | ||
@@ -20,6 +20,8 @@ | ||
}); | ||
exports.redirectToLogin = undefined; | ||
exports.RedirectToSignup = exports.redirectToSignup = exports.redirectToLogin = undefined; | ||
var _regenerator2 = _interopRequireDefault(_regenerator); | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2); | ||
@@ -38,2 +40,3 @@ | ||
var returnTo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.location.href; | ||
var screenHint = arguments[1]; | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
@@ -45,5 +48,5 @@ while (1) { | ||
return _client2.default.loginWithRedirect({ | ||
authorizationParams: { | ||
authorizationParams: (0, _extends3.default)({ | ||
scope: 'openid profile email offline_access' | ||
}, | ||
}, screenHint && { screen_hint: screenHint }), | ||
appState: { returnTo: returnTo } | ||
@@ -65,6 +68,28 @@ }); | ||
var RedirectToLogin = function RedirectToLogin(_ref2) { | ||
var _ref2$returnTo = _ref2.returnTo, | ||
returnTo = _ref2$returnTo === undefined ? window.location.href : _ref2$returnTo; | ||
var redirectToSignup = function () { | ||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2() { | ||
var returnTo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.location.href; | ||
return _regenerator2.default.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
return _context2.abrupt('return', redirectToLogin(returnTo, 'signup')); | ||
case 1: | ||
case 'end': | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2, undefined); | ||
})); | ||
return function redirectToSignup() { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
}(); | ||
var RedirectToLogin = function RedirectToLogin(_ref3) { | ||
var _ref3$returnTo = _ref3.returnTo, | ||
returnTo = _ref3$returnTo === undefined ? window.location.href : _ref3$returnTo; | ||
(0, _react.useEffect)(function () { | ||
@@ -77,4 +102,17 @@ redirectToLogin(returnTo); | ||
var RedirectToSignup = function RedirectToSignup(_ref4) { | ||
var _ref4$returnTo = _ref4.returnTo, | ||
returnTo = _ref4$returnTo === undefined ? window.location.href : _ref4$returnTo; | ||
(0, _react.useEffect)(function () { | ||
redirectToSignup(returnTo); | ||
}, []); | ||
return null; | ||
}; | ||
exports.default = RedirectToLogin; | ||
exports.redirectToLogin = redirectToLogin; | ||
exports.redirectToSignup = redirectToSignup; | ||
exports.RedirectToSignup = RedirectToSignup; | ||
}); |
{ | ||
"name": "@pga/auth-flow-provider", | ||
"version": "1.1.1", | ||
"version": "1.3.0", | ||
"description": "PGA React Auth Provider Package", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
import AuthFlowProvider from './AuthFlowProvider' | ||
import PrivateRoute, { PrivateRouteGatsby } from './PrivateRoute' | ||
import RedirectToLogin, { redirectToLogin } from './RedirectToLogin' | ||
import RedirectToLogin, { redirectToLogin, redirectToSignup, RedirectToSignup } from './RedirectToLogin' | ||
import RedirectToLogout, { redirectToLogout } from './RedirectToLogout' | ||
@@ -16,4 +16,6 @@ import withAuthProvider from './withAuthProvider' | ||
redirectToLogout, | ||
RedirectToSignup, | ||
redirectToSignup, | ||
withAuthProvider, | ||
getToken | ||
} |
import { useEffect } from 'react' | ||
import auth0 from './client' | ||
const redirectToLogin = async (returnTo = window.location.href) => { | ||
const redirectToLogin = async (returnTo = window.location.href, screenHint) => { | ||
await auth0.loginWithRedirect({ | ||
authorizationParams: { | ||
scope: 'openid profile email offline_access' | ||
scope: 'openid profile email offline_access', | ||
...(screenHint && { screen_hint: screenHint }) | ||
}, | ||
@@ -13,2 +14,4 @@ appState: { returnTo } | ||
const redirectToSignup = async (returnTo = window.location.href) => redirectToLogin(returnTo, 'signup') | ||
const RedirectToLogin = ({ returnTo = window.location.href }) => { | ||
@@ -22,3 +25,11 @@ useEffect(() => { | ||
const RedirectToSignup = ({ returnTo = window.location.href }) => { | ||
useEffect(() => { | ||
redirectToSignup(returnTo) | ||
}, []) | ||
return null | ||
} | ||
export default RedirectToLogin | ||
export { redirectToLogin } | ||
export { redirectToLogin, redirectToSignup, RedirectToSignup } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86855
1961