Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
327cc23712 | ||
|
|
9ec2e490a0 | ||
|
|
4cbd705da5 | ||
|
|
330f03f033 | ||
|
|
79708b37ae | ||
|
|
e85f39ebe2 |
No files matched your search
@@ -185,8 +185,16 @@ import SomeProtectedPageComponent from './components/SomeProtectedPageComponent'
|
||||
import SignInPage from './components/SignInPage'
|
||||
import { generateRequireSignInWrapper } from 'redux-token-auth'
|
||||
|
||||
// In this example we set `reduxTokenAuth` as reducer key.
|
||||
// You can set other key name as you like.
|
||||
const mapStateToProps = (state) => ({
|
||||
hasVerificationBeenAttempted: state.reduxTokenAuth.currentUser.hasVerificationBeenAttempted,
|
||||
isSignedIn: state.reduxTokenAuth.currentUser.isSignedIn
|
||||
})
|
||||
|
||||
const requireSignIn = generateRequireSignInWrapper({
|
||||
redirectPathIfNotSignedIn: '/signin',
|
||||
mapStateToProps,
|
||||
})
|
||||
|
||||
const history = createBrowserHistory({})
|
||||
|
||||
+5
-5
@@ -27,12 +27,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var React = require("react");
|
||||
var react_redux_1 = require("react-redux");
|
||||
var generateRequireSignInWrapper = function (_a) {
|
||||
var redirectPathIfNotSignedIn = _a.redirectPathIfNotSignedIn;
|
||||
var redirectPathIfNotSignedIn = _a.redirectPathIfNotSignedIn, mapStateToProps = _a.mapStateToProps;
|
||||
var requireSignInWrapper = function (PageComponent) {
|
||||
var mapStateToProps = function (state) { return ({
|
||||
hasVerificationBeenAttempted: state.reduxTokenAuth.currentUser.hasVerificationBeenAttempted,
|
||||
isSignedIn: state.reduxTokenAuth.currentUser.isSignedIn
|
||||
}); };
|
||||
// const mapStateToProps = (state: ReduxState) => ({
|
||||
// hasVerificationBeenAttempted: state.reduxTokenAuth.currentUser.hasVerificationBeenAttempted,
|
||||
// isSignedIn: state.reduxTokenAuth.currentUser.isSignedIn
|
||||
// })
|
||||
var connector = react_redux_1.connect(mapStateToProps);
|
||||
var GatedPage = /** @class */ (function (_super) {
|
||||
__extends(GatedPage, _super);
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"generate-require-signin-wrapper.js","sourceRoot":"","sources":["../src/generate-require-signin-wrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA8B;AAC9B,2CAAqD;AAMrD,IAAM,4BAA4B,GAAG,UACnC,EAAiE;QAA/D,yBAAyB,+BAAA;IAE3B,IAAM,oBAAoB,GAAG,UAAC,aAA6D;QAEzF,IAAM,eAAe,GAAG,UAAC,KAAiB,IAAK,OAAA,CAAC;YAC9C,4BAA4B,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,4BAA4B;YAC3F,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,UAAU;SACxD,CAAC,EAH6C,CAG7C,CAAA;QAEF,IAAM,SAAS,GAAG,qBAAO,CAAC,eAAe,CAAC,CAAA;QAQ1C;YAAwB,6BAAsB;YAA9C;;YAuBA,CAAC;YAtBQ,sCAAkB,GAAzB;gBACQ,IAAA,KAIF,IAAI,CAAC,KAAK,EAHZ,OAAO,aAAA,EACP,4BAA4B,kCAAA,EAC5B,UAAU,gBACE,CAAA;gBACd,IAAI,4BAA4B,IAAI,CAAC,UAAU,EAAE;oBAC/C,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAA;iBAC3C;YACH,CAAC;YAEM,0BAAM,GAAb;gBACQ,IAAA,KAGF,IAAI,CAAC,KAAK,EAFZ,4BAA4B,kCAAA,EAC5B,UAAU,gBACE,CAAA;gBAEd,OAAO,CAAC,4BAA4B,IAAI,UAAU,CAAC,CAAC,CAAC;oBACnD,oBAAC,aAAa,eAAK,IAAI,CAAC,KAAK,EAAI;oBACjC,CAAC;wBACD,gCAAW,CAAC;YAChB,CAAC;YACH,gBAAC;QAAD,CAAC,AAvBD,CAAwB,KAAK,CAAC,SAAS,GAuBtC;QAED,OAAO,qBAAO,CAC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AC7B,CAAC,CAAA;AAED,kBAAe,4BAA4B,CAAA"}
|
||||
Generated
-5932
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -47,7 +47,7 @@
|
||||
"typescript": "^3.9.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.19.2",
|
||||
"axios": "^0.21.1",
|
||||
"react": "^16.13.1",
|
||||
"react-redux": "^7.2.0",
|
||||
"redux": "^4.0.5",
|
||||
|
||||
@@ -2,18 +2,18 @@ import * as React from 'react'
|
||||
import { connect, ConnectedProps } from 'react-redux'
|
||||
import {
|
||||
GenerateRequireSignInWrapperConfig,
|
||||
ReduxState,
|
||||
// ReduxState,
|
||||
} from './types'
|
||||
|
||||
const generateRequireSignInWrapper = (
|
||||
{ redirectPathIfNotSignedIn }: GenerateRequireSignInWrapperConfig
|
||||
{ redirectPathIfNotSignedIn, mapStateToProps }: GenerateRequireSignInWrapperConfig
|
||||
) => {
|
||||
const requireSignInWrapper = (PageComponent: React.ComponentClass | React.FunctionComponent) => {
|
||||
|
||||
const mapStateToProps = (state: ReduxState) => ({
|
||||
hasVerificationBeenAttempted: state.reduxTokenAuth.currentUser.hasVerificationBeenAttempted,
|
||||
isSignedIn: state.reduxTokenAuth.currentUser.isSignedIn
|
||||
})
|
||||
// const mapStateToProps = (state: ReduxState) => ({
|
||||
// hasVerificationBeenAttempted: state.reduxTokenAuth.currentUser.hasVerificationBeenAttempted,
|
||||
// isSignedIn: state.reduxTokenAuth.currentUser.isSignedIn
|
||||
// })
|
||||
|
||||
const connector = connect(mapStateToProps)
|
||||
type PropsFromRedux = ConnectedProps<typeof connector>
|
||||
|
||||
+5
-4
@@ -19,9 +19,9 @@ export interface ReduxTokenAuthState {
|
||||
readonly currentUser: User
|
||||
}
|
||||
|
||||
export interface ReduxState {
|
||||
readonly reduxTokenAuth: ReduxTokenAuthState
|
||||
}
|
||||
// export interface ReduxState {
|
||||
// readonly reduxTokenAuth: ReduxTokenAuthState
|
||||
// }
|
||||
|
||||
export interface AuthHeaders {
|
||||
readonly 'access-token': string
|
||||
@@ -182,7 +182,7 @@ export type ReduxAction = RegistrationRequestSentAction
|
||||
|
||||
export type AppThunk<ReturnType = Promise<void>> = ThunkAction<
|
||||
ReturnType,
|
||||
ReduxState,
|
||||
object,
|
||||
unknown,
|
||||
Action<string>
|
||||
>
|
||||
@@ -207,6 +207,7 @@ export interface SingleLayerStringMap {
|
||||
|
||||
export interface GenerateRequireSignInWrapperConfig {
|
||||
readonly redirectPathIfNotSignedIn: string
|
||||
readonly mapStateToProps: (state: any) => {hasVerificationBeenAttempted: boolean, isSignedIn: boolean}
|
||||
}
|
||||
|
||||
// export type RequireSignInWrapper = (PageComponent: ComponentClass) => ComponentClass
|
||||
|
||||
@@ -782,12 +782,12 @@ aws4@^1.8.0:
|
||||
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.10.0.tgz#a17b3a8ea811060e74d47d306122400ad4497ae2"
|
||||
integrity sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA==
|
||||
|
||||
axios@^0.19.2:
|
||||
version "0.19.2"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27"
|
||||
integrity sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==
|
||||
axios@^0.21.1:
|
||||
version "0.21.1"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8"
|
||||
integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==
|
||||
dependencies:
|
||||
follow-redirects "1.5.10"
|
||||
follow-redirects "^1.10.0"
|
||||
|
||||
babel-jest@^26.1.0:
|
||||
version "26.1.0"
|
||||
@@ -1177,13 +1177,6 @@ debug@4, debug@^4.1.0, debug@^4.1.1:
|
||||
dependencies:
|
||||
ms "^2.1.1"
|
||||
|
||||
debug@=3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
|
||||
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
|
||||
dependencies:
|
||||
ms "2.0.0"
|
||||
|
||||
debug@^2.2.0, debug@^2.3.3:
|
||||
version "2.6.9"
|
||||
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
|
||||
@@ -1483,12 +1476,10 @@ find-up@^4.0.0, find-up@^4.1.0:
|
||||
locate-path "^5.0.0"
|
||||
path-exists "^4.0.0"
|
||||
|
||||
follow-redirects@1.5.10:
|
||||
version "1.5.10"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a"
|
||||
integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==
|
||||
dependencies:
|
||||
debug "=3.1.0"
|
||||
follow-redirects@^1.10.0:
|
||||
version "1.13.2"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.2.tgz#dd73c8effc12728ba5cf4259d760ea5fb83e3147"
|
||||
integrity sha512-6mPTgLxYm3r6Bkkg0vNM0HTjfGrOEtsfbhagQvbxDEsEkpNhw582upBaoRZylzen6krEmxXJgt9Ju6HiI4O7BA==
|
||||
|
||||
for-in@^1.0.2:
|
||||
version "1.0.2"
|
||||
|
||||
Reference in new issue
Block a user