Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP feat(mfa): new authenticator api #813

Closed
wants to merge 167 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
07f6380
Start to implement authenticator-otp logic
pradel Sep 23, 2019
6ecb9a8
createAuthenticator db interface
pradel Sep 23, 2019
5579e03
mongo createAuthenticator
pradel Sep 23, 2019
ffe9461
Use the createAuthenticator function
pradel Sep 23, 2019
28501a0
Update database-interface.ts
pradel Sep 23, 2019
4c20157
findAuthenticatorById
pradel Sep 23, 2019
d64f319
Update tests
pradel Sep 23, 2019
c08ce36
Update index.ts
pradel Sep 23, 2019
c7fadb0
Update index.ts
pradel Sep 23, 2019
11a9e3e
prepare server
pradel Sep 23, 2019
2072eec
Add comments
pradel Sep 23, 2019
8e5fee6
Better typings
pradel Sep 23, 2019
f7178a0
Merge branch 'master' into feature/authenticator-api
pradel Sep 23, 2019
7c2df0c
Fix lint
pradel Sep 23, 2019
b1931c3
Create rest express route
pradel Sep 23, 2019
50c55bb
Client mfaAssociate
pradel Sep 23, 2019
e46c3cc
cleaner
pradel Sep 23, 2019
b85e80d
Update accounts-client.ts
pradel Sep 23, 2019
3f3d6b8
try the associate endpoint with the REST example
pradel Sep 23, 2019
e422e64
Update example ui
pradel Sep 23, 2019
5a58b4f
Add an active field
pradel Sep 24, 2019
086aff2
Update index.ts
pradel Sep 24, 2019
bdb683e
Mongo findUserAuthenticators
pradel Sep 24, 2019
51881d8
use const
pradel Sep 24, 2019
fcd4262
expose `findUserAuthenticators`
pradel Sep 24, 2019
46c87f4
Start writting OTP documentation
pradel Sep 24, 2019
df70b3b
Update otp.md
pradel Sep 24, 2019
35f8bdb
missing id in interface
pradel Sep 30, 2019
eb05aca
Update index.ts
pradel Sep 30, 2019
e196bc7
Merge branch 'master' into feature/authenticator-api
pradel Nov 18, 2019
08d5aca
Update package.json
pradel Nov 18, 2019
75a67ad
Update
pradel Nov 18, 2019
4f32a70
Upgrade deps
pradel Nov 18, 2019
b04d24a
extract the user id for mfa associate
pradel Nov 18, 2019
e275fa9
upgrade more deps
pradel Nov 18, 2019
c075449
Prepare mfaChallengeCollection for mongo
pradel Nov 19, 2019
61c0c2b
createMfaChallenge
pradel Nov 19, 2019
03cf80b
Fix
pradel Nov 19, 2019
476e473
findMfaChallengeByToken
pradel Nov 19, 2019
b8f574a
Create a new challenge when we associate a new authenticator
pradel Nov 19, 2019
a9a8553
Add some comment
pradel Nov 19, 2019
767349b
Activate an authenticator
pradel Dec 1, 2019
50aa33d
Add functions to database manager
pradel Dec 13, 2019
1a8761e
Upgrade deps
pradel Dec 13, 2019
bccefc7
Documentation "Confirm the association"
pradel Dec 13, 2019
4319e30
Add activatedAt to authenticator type
pradel Dec 13, 2019
1b5b7cb
Finish authenticator registration flow
pradel Dec 13, 2019
49d0ce5
cleanup types
pradel Dec 13, 2019
af61d8c
Do the same for sessions
pradel Dec 13, 2019
99ccdf4
upgrade react-scripts
pradel Dec 13, 2019
87f5bac
Fix express authenticators route
pradel Dec 15, 2019
5285bab
Start security page
pradel Dec 15, 2019
a015bb6
Merge branch 'master' of github.com:accounts-js/accounts into feature…
pradel Jan 20, 2020
78b3ad0
Fix package version
pradel Jan 20, 2020
8186630
Update TwoFactor.tsx
pradel Jan 20, 2020
6026388
cleanup example
pradel Jan 20, 2020
78f430a
Cleanup example
pradel Jan 21, 2020
b0cdf0b
show otp error
pradel Jan 21, 2020
216b0b9
Update TwoFactorOtp.tsx
pradel Jan 21, 2020
5aa5b13
redirect on success
pradel Jan 21, 2020
437511c
remove duplicate key prop
pradel Jan 21, 2020
8eba4a3
add options to otp doc
pradel Feb 27, 2020
466fe98
Update otp.md
pradel Feb 27, 2020
d93cb52
Merge branch 'master' into feature/authenticator-api
pradel Apr 9, 2020
a7d9d18
Update package.json
pradel Apr 9, 2020
e936ad9
revert
pradel Apr 9, 2020
53453c0
Update graphql-client.ts
pradel Apr 9, 2020
fe2f6b6
pass compilation
pradel Apr 9, 2020
bfcf4bc
Update findUserAuthenticators description
pradel Apr 14, 2020
b4b51d3
Add sanitize method
pradel Apr 14, 2020
f008571
Merge branch 'master' of github.com:accounts-js/accounts into feature…
pradel Apr 14, 2020
2520896
prettier
pradel Apr 14, 2020
2a1bd57
Fix ts compilation
pradel Apr 14, 2020
3a70723
Update accounts-server.ts
pradel Apr 14, 2020
c773d3e
fix otp lint
pradel Apr 14, 2020
177fd40
comments
pradel Apr 16, 2020
59f2563
add some doc
pradel Apr 16, 2020
df9ecff
Merge branch 'master' of github.com:accounts-js/accounts into feature…
pradel Apr 17, 2020
9fc0869
Update package.json
pradel Apr 17, 2020
0e9eb3b
v0.26.0-alpha.0
pradel Apr 17, 2020
9d7a982
require factor on login
pradel Apr 17, 2020
1baa377
Fix build
pradel Apr 17, 2020
1efdd1f
move AuthenticationResult to types
pradel Apr 17, 2020
8e5e7e6
Fix client login type
pradel Apr 20, 2020
ff47931
redirect to mfa route if needed
pradel Apr 20, 2020
225893f
create LoginMfa
pradel Apr 20, 2020
03eb9dd
Allow user to list authenticators with mfaToken
pradel Apr 20, 2020
8a0b9e8
add TODO
pradel Apr 20, 2020
0a02e65
Merge branch 'master' of github.com:accounts-js/accounts into feature…
pradel Apr 20, 2020
27dbb59
add updateMfaChallenge
pradel Apr 21, 2020
236df51
create mfaChallenge
pradel Apr 21, 2020
a35076d
fix mfa challenge
pradel Apr 21, 2020
65b33f6
example use challenge
pradel Apr 21, 2020
5a04d72
fix merge with master
pradel Apr 21, 2020
9ba2ea9
Fix build step
pradel Apr 21, 2020
4554965
Add Vocabulary
pradel Apr 21, 2020
092fec2
Example link to setup the first authenticator from the settings
pradel Apr 21, 2020
97c94dc
fix lint
pradel Apr 21, 2020
facd74f
Prepare MfaAuthenticator screen
pradel Apr 21, 2020
ce6f044
v0.26.0-alpha.1
pradel Apr 21, 2020
246b76b
convertAuthenticatorIdToMongoObjectId and convertMfaChallengeIdToMong…
pradel Apr 22, 2020
4008cfc
graphql api mfa module
pradel Apr 23, 2020
294bd58
client authenticators query
pradel Apr 23, 2020
1308142
client challengeMutation
pradel Apr 23, 2020
a837c07
Merge branch 'master' of github.com:accounts-js/accounts into feature…
pradel Apr 23, 2020
124af74
change options for authenticator interface
pradel Apr 24, 2020
ad09148
v0.26.0-alpha.2
pradel Apr 24, 2020
3ab5c05
Merge branch 'master' of github.com:accounts-js/accounts into feature…
pradel Apr 24, 2020
efdc085
Merge branch 'master' of github.com:accounts-js/accounts into feature…
pradel Apr 29, 2020
5a3130f
rename mfaChallengeCollection to mfaChallengeCollectionName
pradel Apr 29, 2020
4c0dd92
fix bad merge
pradel Apr 29, 2020
c222893
Allow challenge to return any data to the client
pradel Apr 29, 2020
7d84539
option to enforce to register a new authenticator before login
pradel May 4, 2020
c117b89
v0.26.0-alpha.3
pradel May 4, 2020
01a8d44
Merge branch 'master' of github.com:accounts-js/accounts into feature…
pradel May 4, 2020
c5ece89
fix lint
pradel May 4, 2020
41f7ce2
fix database-manager tests
pradel May 4, 2020
f686afc
Fix graphql ChallengeResult
pradel May 7, 2020
8c5becb
separate mfa token operations
pradel May 7, 2020
df64531
v0.26.0-alpha.4
pradel May 7, 2020
619762e
Merge branch 'master' of github.com:accounts-js/accounts into feature…
pradel Jun 16, 2020
b758939
Merge branch 'master' of github.com:accounts-js/accounts into feature…
pradel Jun 16, 2020
aa2e296
Update package.json
pradel Jun 16, 2020
40a13f5
fix compilation
pradel Jun 16, 2020
546d385
cleanup types
pradel Jun 16, 2020
0cdde15
update db
pradel Jun 16, 2020
3d42b39
add deactivateAuthenticator
pradel Jun 16, 2020
4e8f6ce
allow custom params for associate
pradel Jun 16, 2020
3c35081
allow custom associate params from client
pradel Jun 16, 2020
b10af60
Update package.json
pradel Jun 16, 2020
9d3a051
v0.28.0-alpha.0
pradel Jun 16, 2020
abe04ef
named import otplib
pradel Jun 18, 2020
245c43c
improve authenticator-otp tests
pradel Jun 18, 2020
5e2701b
Merge branch 'master' into feature/authenticator-api
pradel Jul 17, 2020
c1479e1
fix graphql client queries and mutations
pradel Jul 17, 2020
03d0aad
fix other client issues
pradel Jul 20, 2020
cdeb32e
v0.28.0-alpha.1
pradel Jul 20, 2020
609e890
feat(types): create database mfa types (#1035)
pradel Aug 6, 2020
7c755b0
feat(mongo): implement mfa methods (#1036)
pradel Aug 6, 2020
5adade4
Merge branch 'master' into feature/authenticator-api
pradel Aug 6, 2020
a8dbc34
fix graphql-client
pradel Aug 6, 2020
e30fb58
chore: upgrade jest (#1037)
pradel Aug 6, 2020
b0814be
chore: use yarn v2 berry (#1041)
pradel Aug 10, 2020
dc8c049
feat(mfa): create new mfa service (#1038)
pradel Aug 10, 2020
38279ed
Merge branch 'master' into feature/authenticator-api
pradel Aug 10, 2020
e347fd4
Update index.ts
pradel Aug 10, 2020
61aabe3
update
pradel Aug 10, 2020
debd092
feat(otp): create otp factor (#1042)
pradel Aug 10, 2020
2ef5d6e
Merge branch 'master' into feature/authenticator-api
pradel Aug 10, 2020
938ff04
delete
pradel Aug 10, 2020
6265362
fix(rest-example): fix mongo usage (#1043)
pradel Aug 10, 2020
8331c47
chore: upgrade deps (#1044)
pradel Aug 10, 2020
0ea3f05
Merge branch 'master' into feature/authenticator-api
pradel Aug 11, 2020
be084d8
changes
pradel Aug 11, 2020
3e930bc
feat(server)!: loginWithService return challenge (#1045)
pradel Aug 12, 2020
cf1c800
Merge branch 'master' into feature/authenticator-api
pradel Aug 12, 2020
2d80d34
fix
pradel Aug 12, 2020
8738f6e
feat(rest-express): create mfa endpoints (#1047)
pradel Aug 12, 2020
f563464
merge
pradel Aug 12, 2020
c701294
Update express-middleware.ts
pradel Aug 12, 2020
976a1e9
Update provider-callback.ts
pradel Aug 12, 2020
02e8b10
Update express-middleware.ts
pradel Aug 12, 2020
a9d890c
feat(graphql-api): create mfa operations (#1048)
pradel Aug 13, 2020
3d8ef0c
Merge branch 'master' into feature/authenticator-api
pradel Aug 13, 2020
dc9d675
Update accounts-server.ts
pradel Aug 13, 2020
b1eb1b2
feat(client): add mfa operations (#1049)
pradel Aug 13, 2020
d432edd
Merge branch 'master' into feature/authenticator-api
pradel Aug 13, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: docker-compose up -d
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
Expand All @@ -29,9 +29,7 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Lerna bootstrap
run: yarn run lerna bootstrap
run: yarn install --immutable
- name: Check lint
run: yarn test:lint
- name: Compile packages
Expand All @@ -48,7 +46,6 @@ jobs:
- name: Test documentation
run: |
cd website
yarn install --frozen-lockfile
yarn generate-api-docs
yarn build
env:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ yarn-error.log
packages/*/package-lock.json
schema.json
.DS_Store

build/
.yarn/*
!.yarn/releases
!.yarn/plugins
.pnp.*
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ packages/graphql-api/src/models.ts
packages/graphql-client/src/graphql-operations.ts
website/.docusaurus
website/docs/api
.yarn
38 changes: 38 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

106,764 changes: 106,764 additions & 0 deletions .yarn/releases/yarn-berry.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn-berry.js
# We use the node linker because some modules are not compatible with Plug'n'Play
# - graphql-codegen is failing
nodeLinker: node-modules
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ The Accounts project was intended - since its inception - to be a community main
#### Useful Commands:

- Install project dependencies: `yarn`
- Link together all the packages: `yarn setup`
- Compile the packages `yarn compile`
- Watch the packages for changes and recompile: `yarn start` (You need to run this command in the package subfolder you are updating)
- If you want to use the accounts project in your own project, use `yarn link @accounts/<name of package>` within your project.
Expand Down Expand Up @@ -64,7 +63,7 @@ Anyone can file an expense. If the expense makes sense for the development of th
### Contributors

Thank you to all the people who have already contributed to accounts-js!
<a href="graphs/contributors"><img src="https://opencollective.com/accounts-js/contributors.svg?width=890" /></a>
<a href="https://github.com/accounts-js/accounts/graphs/contributors"><img src="https://opencollective.com/accounts-js/contributors.svg?width=890" /></a>

### Backers

Expand Down
16 changes: 8 additions & 8 deletions examples/accounts-boost/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
},
"dependencies": {
"@accounts/boost": "^0.29.0",
"@graphql-tools/merge": "6.0.11",
"@graphql-tools/merge": "6.0.16",
"apollo-link-context": "1.0.20",
"apollo-link-http": "1.5.17",
"apollo-server": "2.14.4",
"graphql": "14.6.0",
"apollo-server": "2.16.1",
"graphql": "14.7.0",
"graphql-tools": "5.0.0",
"lodash": "4.17.15",
"lodash": "4.17.19",
"node-fetch": "2.6.0",
"tslib": "2.0.0"
"tslib": "2.0.1"
},
"devDependencies": {
"nodemon": "2.0.3",
"ts-node": "8.10.1",
"typescript": "3.8.3"
"nodemon": "2.0.4",
"ts-node": "8.10.2",
"typescript": "3.9.7"
}
}
1 change: 0 additions & 1 deletion examples/graphql-server-typeorm-postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ In order to be able to run this example on your machine you first need to do the

- Clone the repository `git clone [email protected]:accounts-js/accounts.git`
- Install project dependencies: `yarn`
- Link together all the packages: `yarn setup`
- Compile the packages `yarn compile`
- Go to the example folder `cd examples/graphql-server-typeorm-postgres`

Expand Down
16 changes: 8 additions & 8 deletions examples/graphql-server-typeorm-postgres/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
"@accounts/server": "^0.29.0",
"@accounts/typeorm": "^0.29.0",
"@graphql-modules/core": "0.7.17",
"@graphql-tools/merge": "6.0.11",
"apollo-server": "2.14.4",
"@graphql-tools/merge": "6.0.16",
"apollo-server": "2.16.1",
"dotenv": "^8.2.0",
"graphql": "14.6.0",
"pg": "8.1.0",
"graphql": "14.7.0",
"pg": "8.3.0",
"typeorm": "0.2.25"
},
"devDependencies": {
"@accounts/types": "^0.29.0",
"@types/node": "14.0.13",
"nodemon": "2.0.3",
"ts-node": "8.10.1",
"typescript": "3.8.3"
"@types/node": "14.0.27",
"nodemon": "2.0.4",
"ts-node": "8.10.2",
"typescript": "3.9.7"
}
}
1 change: 0 additions & 1 deletion examples/graphql-server-typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ In order to be able to run this example on your machine you first need to do the

- Clone the repository `git clone [email protected]:accounts-js/accounts.git`
- Install project dependencies: `yarn`
- Link together all the packages: `yarn setup`
- Compile the packages `yarn compile`
- Go to the example folder `cd examples/graphql-server-typescript`

Expand Down
14 changes: 7 additions & 7 deletions examples/graphql-server-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
"@accounts/rest-express": "^0.29.0",
"@accounts/server": "^0.29.0",
"@graphql-modules/core": "0.7.17",
"@graphql-tools/merge": "6.0.11",
"apollo-server": "2.16.0",
"graphql": "14.6.0",
"@graphql-tools/merge": "6.0.16",
"apollo-server": "2.16.1",
"graphql": "14.7.0",
"lodash": "4.17.19",
"mongoose": "5.9.25",
"tslib": "2.0.0"
"mongoose": "5.9.28",
"tslib": "2.0.1"
},
"devDependencies": {
"@types/mongoose": "5.7.32",
"@types/node": "14.0.13",
"@types/mongoose": "5.7.36",
"@types/node": "14.0.27",
"nodemon": "2.0.4",
"ts-node": "8.10.2",
"typescript": "3.9.7"
Expand Down
1 change: 0 additions & 1 deletion examples/react-graphql-typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ In order to be able to run this example on your machine you first need to do the

- Clone the repository `git clone [email protected]:accounts-js/accounts.git`
- Install project dependencies: `yarn`
- Link together all the packages: `yarn setup`
- Compile the packages `yarn compile`
- Go to the example folder `cd examples/react-graphql-typescript`

Expand Down
12 changes: 6 additions & 6 deletions examples/react-graphql-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@
"@accounts/client": "^0.29.0",
"@accounts/client-password": "^0.29.0",
"@accounts/graphql-client": "^0.29.0",
"@apollo/client": "3.0.2",
"@apollo/client": "3.1.3",
"@material-ui/core": "4.11.0",
"@material-ui/styles": "4.10.0",
"graphql": "14.6.0",
"graphql-tag": "2.10.4",
"graphql": "14.7.0",
"graphql-tag": "2.11.0",
"qrcode.react": "1.0.0",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-router-dom": "5.2.0",
"tslib": "2.0.0"
"tslib": "2.0.1"
},
"devDependencies": {
"@types/node": "14.0.13",
"@types/node": "14.0.27",
"@types/qrcode.react": "1.0.1",
"@types/react": "16.9.43",
"@types/react": "16.9.45",
"@types/react-dom": "16.9.8",
"@types/react-router": "5.1.8",
"@types/react-router-dom": "5.1.5",
Expand Down
1 change: 0 additions & 1 deletion examples/react-rest-typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ In order to be able to run this example on your machine you first need to do the

- Clone the repository `git clone [email protected]:accounts-js/accounts.git`
- Install project dependencies: `yarn`
- Link together all the packages: `yarn setup`
- Compile the packages `yarn compile`
- Go to the example folder `cd examples/react-rest-typescript`

Expand Down
22 changes: 11 additions & 11 deletions examples/react-rest-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@
"@accounts/client": "^0.29.0",
"@accounts/client-password": "^0.29.0",
"@accounts/rest-client": "^0.29.0",
"@material-ui/core": "4.9.13",
"@material-ui/core": "4.11.0",
"@material-ui/icons": "4.9.1",
"@material-ui/lab": "4.0.0-alpha.50",
"@material-ui/styles": "4.9.13",
"formik": "2.1.4",
"@material-ui/lab": "4.0.0-alpha.56",
"@material-ui/styles": "4.10.0",
"formik": "2.1.5",
"qrcode.react": "1.0.0",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-router-dom": "5.1.2",
"tslib": "2.0.0"
"react-router-dom": "5.2.0",
"tslib": "2.0.1"
},
"devDependencies": {
"@types/node": "14.0.13",
"@types/qrcode.react": "1.0.0",
"@types/react": "16.9.36",
"@types/node": "14.0.27",
"@types/qrcode.react": "1.0.1",
"@types/react": "16.9.45",
"@types/react-dom": "16.9.8",
"@types/react-router": "5.1.7",
"@types/react-router": "5.1.8",
"@types/react-router-dom": "5.1.5",
"react-scripts": "3.4.1",
"typescript": "3.7.5"
"typescript": "3.9.7"
}
}
25 changes: 7 additions & 18 deletions examples/react-rest-typescript/src/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { SnackBarContentError } from './components/SnackBarContentError';
import { useAuth } from './components/AuthContext';
import { UnauthenticatedContainer } from './components/UnauthenticatedContainer';

const useStyles = makeStyles(theme => ({
const useStyles = makeStyles((theme) => ({
cardContent: {
padding: theme.spacing(3),
},
Expand All @@ -41,7 +41,6 @@ const ResetPasswordLink = React.forwardRef<RouterLink, any>((props, ref) => (
interface LoginValues {
email: string;
password: string;
code: string;
}

const Login = ({ history }: RouteComponentProps<{}>) => {
Expand All @@ -52,9 +51,8 @@ const Login = ({ history }: RouteComponentProps<{}>) => {
initialValues: {
email: '',
password: '',
code: '',
},
validate: values => {
validate: (values) => {
const errors: FormikErrors<LoginValues> = {};
if (!values.email) {
errors.email = 'Required';
Expand All @@ -66,13 +64,16 @@ const Login = ({ history }: RouteComponentProps<{}>) => {
},
onSubmit: async (values, { setSubmitting }) => {
try {
await loginWithService('password', {
const loginResponse = await loginWithService('password', {
user: {
email: values.email,
},
password: values.password,
code: values.code,
});
if ('mfaToken' in loginResponse) {
history.push('/login/mfa', { mfaToken: loginResponse.mfaToken });
return;
}
history.push('/');
} catch (error) {
setError(error.message);
Expand Down Expand Up @@ -130,18 +131,6 @@ const Login = ({ history }: RouteComponentProps<{}>) => {
helperText={formik.touched.password && formik.errors.password}
/>
</Grid>
<Grid item xs={12}>
<TextField
label="2fa code if enabled"
variant="outlined"
fullWidth={true}
id="code"
value={formik.values.code}
onChange={formik.handleChange}
error={Boolean(formik.errors.code && formik.touched.code)}
helperText={formik.touched.code && formik.errors.code}
/>
</Grid>
<Grid item xs={12} md={6}>
<Button
variant="contained"
Expand Down
Loading