Commit cf746962 authored by Ermolaev Timur's avatar Ermolaev Timur

Merge branch 'task-31-feature/connect_registration_login_with_back' into 'development'

Task 31 feature/connect registration login with back

See merge request !19
parents ba39a466 17659ca3
...@@ -18,13 +18,16 @@ ...@@ -18,13 +18,16 @@
"cors": "^2.8.5", "cors": "^2.8.5",
"express": "^4.18.2", "express": "^4.18.2",
"mongoose": "^6.7.0", "mongoose": "^6.7.0",
"multer": "^1.4.5-lts.1",
"nanoid": "^3.3.4", "nanoid": "^3.3.4",
"path": "^0.12.7",
"pg": "^8.8.0", "pg": "^8.8.0",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"typeorm": "^0.3.10" "typeorm": "^0.3.10"
}, },
"devDependencies": { "devDependencies": {
"@faker-js/faker": "^7.6.0", "@faker-js/faker": "^7.6.0",
"@types/multer": "^1.4.7",
"@types/node": "^18.11.8", "@types/node": "^18.11.8",
"@typescript-eslint/eslint-plugin": "^5.41.0", "@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0", "@typescript-eslint/parser": "^5.41.0",
...@@ -1695,6 +1698,15 @@ ...@@ -1695,6 +1698,15 @@
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz",
"integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==" "integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA=="
}, },
"node_modules/@types/multer": {
"version": "1.4.7",
"resolved": "https://registry.npmjs.org/@types/multer/-/multer-1.4.7.tgz",
"integrity": "sha512-/SNsDidUFCvqqcWDwxv2feww/yqhNeTRL5CVoL3jU4Goc4kKEL10T7Eye65ZqPNi4HRx8sAEX59pV1aEH7drNA==",
"dev": true,
"dependencies": {
"@types/express": "*"
}
},
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "18.11.8", "version": "18.11.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.8.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.8.tgz",
...@@ -2205,6 +2217,11 @@ ...@@ -2205,6 +2217,11 @@
"node": ">= 6.0.0" "node": ">= 6.0.0"
} }
}, },
"node_modules/append-field": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz",
"integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw=="
},
"node_modules/aproba": { "node_modules/aproba": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz",
...@@ -2449,6 +2466,11 @@ ...@@ -2449,6 +2466,11 @@
"ieee754": "^1.1.13" "ieee754": "^1.1.13"
} }
}, },
"node_modules/buffer-from": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="
},
"node_modules/buffer-writer": { "node_modules/buffer-writer": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz", "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz",
...@@ -2457,6 +2479,17 @@ ...@@ -2457,6 +2479,17 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/busboy": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
"integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
"dependencies": {
"streamsearch": "^1.1.0"
},
"engines": {
"node": ">=10.16.0"
}
},
"node_modules/bytes": { "node_modules/bytes": {
"version": "3.1.2", "version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
...@@ -2705,6 +2738,47 @@ ...@@ -2705,6 +2738,47 @@
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
}, },
"node_modules/concat-stream": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
"engines": [
"node >= 0.8"
],
"dependencies": {
"buffer-from": "^1.0.0",
"inherits": "^2.0.3",
"readable-stream": "^2.2.2",
"typedarray": "^0.0.6"
}
},
"node_modules/concat-stream/node_modules/readable-stream": {
"version": "2.3.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
"integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
"dependencies": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
}
},
"node_modules/concat-stream/node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"node_modules/concat-stream/node_modules/string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"dependencies": {
"safe-buffer": "~5.1.0"
}
},
"node_modules/console-control-strings": { "node_modules/console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
...@@ -2745,9 +2819,7 @@ ...@@ -2745,9 +2819,7 @@
"node_modules/core-util-is": { "node_modules/core-util-is": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
"optional": true,
"peer": true
}, },
"node_modules/cors": { "node_modules/cors": {
"version": "2.8.5", "version": "2.8.5",
...@@ -3861,9 +3933,7 @@ ...@@ -3861,9 +3933,7 @@
"node_modules/isarray": { "node_modules/isarray": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ=="
"optional": true,
"peer": true
}, },
"node_modules/isexe": { "node_modules/isexe": {
"version": "2.0.0", "version": "2.0.0",
...@@ -4119,6 +4189,14 @@ ...@@ -4119,6 +4189,14 @@
"node": "*" "node": "*"
} }
}, },
"node_modules/minimist": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
"integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/minipass": { "node_modules/minipass": {
"version": "3.3.4", "version": "3.3.4",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz", "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz",
...@@ -4304,6 +4382,34 @@ ...@@ -4304,6 +4382,34 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
}, },
"node_modules/multer": {
"version": "1.4.5-lts.1",
"resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz",
"integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==",
"dependencies": {
"append-field": "^1.0.0",
"busboy": "^1.0.0",
"concat-stream": "^1.5.2",
"mkdirp": "^0.5.4",
"object-assign": "^4.1.1",
"type-is": "^1.6.4",
"xtend": "^4.0.0"
},
"engines": {
"node": ">= 6.0.0"
}
},
"node_modules/multer/node_modules/mkdirp": {
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
"dependencies": {
"minimist": "^1.2.6"
},
"bin": {
"mkdirp": "bin/cmd.js"
}
},
"node_modules/mz": { "node_modules/mz": {
"version": "2.7.0", "version": "2.7.0",
"resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz",
...@@ -4592,6 +4698,15 @@ ...@@ -4592,6 +4698,15 @@
"node": ">= 0.8" "node": ">= 0.8"
} }
}, },
"node_modules/path": {
"version": "0.12.7",
"resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
"integrity": "sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==",
"dependencies": {
"process": "^0.11.1",
"util": "^0.10.3"
}
},
"node_modules/path-exists": { "node_modules/path-exists": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
...@@ -4771,12 +4886,18 @@ ...@@ -4771,12 +4886,18 @@
"node": ">= 0.8.0" "node": ">= 0.8.0"
} }
}, },
"node_modules/process": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
"integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==",
"engines": {
"node": ">= 0.6.0"
}
},
"node_modules/process-nextick-args": { "node_modules/process-nextick-args": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
"optional": true,
"peer": true
}, },
"node_modules/proxy-addr": { "node_modules/proxy-addr": {
"version": "2.0.7", "version": "2.0.7",
...@@ -5219,6 +5340,14 @@ ...@@ -5219,6 +5340,14 @@
"node": ">= 0.8" "node": ">= 0.8"
} }
}, },
"node_modules/streamsearch": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
"integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==",
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/string_decoder": { "node_modules/string_decoder": {
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
...@@ -5474,6 +5603,11 @@ ...@@ -5474,6 +5603,11 @@
"node": ">= 0.6" "node": ">= 0.6"
} }
}, },
"node_modules/typedarray": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
"integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA=="
},
"node_modules/typeorm": { "node_modules/typeorm": {
"version": "0.3.10", "version": "0.3.10",
"resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.10.tgz", "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.10.tgz",
...@@ -5746,11 +5880,24 @@ ...@@ -5746,11 +5880,24 @@
"punycode": "^2.1.0" "punycode": "^2.1.0"
} }
}, },
"node_modules/util": {
"version": "0.10.4",
"resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
"integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
"dependencies": {
"inherits": "2.0.3"
}
},
"node_modules/util-deprecate": { "node_modules/util-deprecate": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
}, },
"node_modules/util/node_modules/inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw=="
},
"node_modules/utils-merge": { "node_modules/utils-merge": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
...@@ -7502,6 +7649,15 @@ ...@@ -7502,6 +7649,15 @@
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz",
"integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==" "integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA=="
}, },
"@types/multer": {
"version": "1.4.7",
"resolved": "https://registry.npmjs.org/@types/multer/-/multer-1.4.7.tgz",
"integrity": "sha512-/SNsDidUFCvqqcWDwxv2feww/yqhNeTRL5CVoL3jU4Goc4kKEL10T7Eye65ZqPNi4HRx8sAEX59pV1aEH7drNA==",
"dev": true,
"requires": {
"@types/express": "*"
}
},
"@types/node": { "@types/node": {
"version": "18.11.8", "version": "18.11.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.8.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.8.tgz",
...@@ -7841,6 +7997,11 @@ ...@@ -7841,6 +7997,11 @@
"resolved": "https://registry.npmjs.org/app-root-path/-/app-root-path-3.1.0.tgz", "resolved": "https://registry.npmjs.org/app-root-path/-/app-root-path-3.1.0.tgz",
"integrity": "sha512-biN3PwB2gUtjaYy/isrU3aNWI5w+fAfvHkSvCKeQGxhmYpwKFUxudR3Yya+KqVRHBmEDYh+/lTozYCFbmzX4nA==" "integrity": "sha512-biN3PwB2gUtjaYy/isrU3aNWI5w+fAfvHkSvCKeQGxhmYpwKFUxudR3Yya+KqVRHBmEDYh+/lTozYCFbmzX4nA=="
}, },
"append-field": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz",
"integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw=="
},
"aproba": { "aproba": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz",
...@@ -8035,11 +8196,24 @@ ...@@ -8035,11 +8196,24 @@
"ieee754": "^1.1.13" "ieee754": "^1.1.13"
} }
}, },
"buffer-from": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="
},
"buffer-writer": { "buffer-writer": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz", "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz",
"integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==" "integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw=="
}, },
"busboy": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
"integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
"requires": {
"streamsearch": "^1.1.0"
}
},
"bytes": { "bytes": {
"version": "3.1.2", "version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
...@@ -8226,6 +8400,46 @@ ...@@ -8226,6 +8400,46 @@
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
}, },
"concat-stream": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
"requires": {
"buffer-from": "^1.0.0",
"inherits": "^2.0.3",
"readable-stream": "^2.2.2",
"typedarray": "^0.0.6"
},
"dependencies": {
"readable-stream": {
"version": "2.3.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
"integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
}
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"requires": {
"safe-buffer": "~5.1.0"
}
}
}
},
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
...@@ -8257,9 +8471,7 @@ ...@@ -8257,9 +8471,7 @@
"core-util-is": { "core-util-is": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
"optional": true,
"peer": true
}, },
"cors": { "cors": {
"version": "2.8.5", "version": "2.8.5",
...@@ -9097,9 +9309,7 @@ ...@@ -9097,9 +9309,7 @@
"isarray": { "isarray": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ=="
"optional": true,
"peer": true
}, },
"isexe": { "isexe": {
"version": "2.0.0", "version": "2.0.0",
...@@ -9300,6 +9510,11 @@ ...@@ -9300,6 +9510,11 @@
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
}, },
"minimist": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
"integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g=="
},
"minipass": { "minipass": {
"version": "3.3.4", "version": "3.3.4",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz", "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz",
...@@ -9422,6 +9637,30 @@ ...@@ -9422,6 +9637,30 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
}, },
"multer": {
"version": "1.4.5-lts.1",
"resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz",
"integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==",
"requires": {
"append-field": "^1.0.0",
"busboy": "^1.0.0",
"concat-stream": "^1.5.2",
"mkdirp": "^0.5.4",
"object-assign": "^4.1.1",
"type-is": "^1.6.4",
"xtend": "^4.0.0"
},
"dependencies": {
"mkdirp": {
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
"requires": {
"minimist": "^1.2.6"
}
}
}
},
"mz": { "mz": {
"version": "2.7.0", "version": "2.7.0",
"resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz",
...@@ -9639,6 +9878,15 @@ ...@@ -9639,6 +9878,15 @@
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="
}, },
"path": {
"version": "0.12.7",
"resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
"integrity": "sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==",
"requires": {
"process": "^0.11.1",
"util": "^0.10.3"
}
},
"path-exists": { "path-exists": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
...@@ -9763,12 +10011,15 @@ ...@@ -9763,12 +10011,15 @@
"integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==",
"dev": true "dev": true
}, },
"process": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
"integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A=="
},
"process-nextick-args": { "process-nextick-args": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
"optional": true,
"peer": true
}, },
"proxy-addr": { "proxy-addr": {
"version": "2.0.7", "version": "2.0.7",
...@@ -10079,6 +10330,11 @@ ...@@ -10079,6 +10330,11 @@
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
"integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ=="
}, },
"streamsearch": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
"integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg=="
},
"string_decoder": { "string_decoder": {
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
...@@ -10258,6 +10514,11 @@ ...@@ -10258,6 +10514,11 @@
"mime-types": "~2.1.24" "mime-types": "~2.1.24"
} }
}, },
"typedarray": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
"integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA=="
},
"typeorm": { "typeorm": {
"version": "0.3.10", "version": "0.3.10",
"resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.10.tgz", "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.10.tgz",
...@@ -10398,6 +10659,21 @@ ...@@ -10398,6 +10659,21 @@
"punycode": "^2.1.0" "punycode": "^2.1.0"
} }
}, },
"util": {
"version": "0.10.4",
"resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
"integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
"requires": {
"inherits": "2.0.3"
},
"dependencies": {
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw=="
}
}
},
"util-deprecate": { "util-deprecate": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"@faker-js/faker": "^7.6.0", "@faker-js/faker": "^7.6.0",
"@types/multer": "^1.4.7",
"@types/node": "^18.11.8", "@types/node": "^18.11.8",
"@typescript-eslint/eslint-plugin": "^5.41.0", "@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0", "@typescript-eslint/parser": "^5.41.0",
...@@ -34,7 +35,9 @@ ...@@ -34,7 +35,9 @@
"cors": "^2.8.5", "cors": "^2.8.5",
"express": "^4.18.2", "express": "^4.18.2",
"mongoose": "^6.7.0", "mongoose": "^6.7.0",
"multer": "^1.4.5-lts.1",
"nanoid": "^3.3.4", "nanoid": "^3.3.4",
"path": "^0.12.7",
"pg": "^8.8.0", "pg": "^8.8.0",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"typeorm": "^0.3.10" "typeorm": "^0.3.10"
......
*
!.gitignore
!_ACzV5N3r69BCMdpyqmGC.png
!lDmNHjGy5I2g1mWMR-n_c.png
!ExATi9O98uKnHxJ_wqUS2.png
!Aqvv8P8AgL_1xfC93CLKp.png
!NqUZ1Tq8pxbVptmhZPKcd.png
!46AlFQI4qKG2GpuJGdKbG.png
!ip5KgNCs30o3djHb8V_GR.png
!1tlFOumiL3MmH89O8OO6H.png
!nTVRV1ZePPe7tTIdGKKfX.png
\ No newline at end of file
import path = require('path');
const rootPath = __dirname;
export const config = {
rootPath,
uploadPath: path.join(rootPath, "public", "uploads"),
db: {
url: "mongodb://localhost/",
name: "planner"
}
};
...@@ -2,10 +2,25 @@ import express,{Router, Request, Response} from 'express'; ...@@ -2,10 +2,25 @@ import express,{Router, Request, Response} from 'express';
import {User} from '../models/User'; import {User} from '../models/User';
import {myDataSource} from '../app-data-source'; import {myDataSource} from '../app-data-source';
import { nanoid } from 'nanoid'; import { nanoid } from 'nanoid';
import multer = require('multer');
import path = require("path");
import {config} from "../config"
const router:Router = express.Router(); const router:Router = express.Router();
const dataSource = myDataSource; const dataSource = myDataSource;
const storage = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, config.uploadPath);
},
filename: (req, file, cb) => {
cb(null, nanoid() + path.extname(file.originalname));
}
})
const upload = multer({ storage })
router.get('/', async (req : Request, res : Response):Promise<object> => { router.get('/', async (req : Request, res : Response):Promise<object> => {
const users = await dataSource const users = await dataSource
.getRepository(User) .getRepository(User)
...@@ -15,9 +30,10 @@ return res.send({users}) ...@@ -15,9 +30,10 @@ return res.send({users})
}) })
router.post('/', async (req : Request, res : Response):Promise<object> => { router.post('/', upload.single("avatar"), async (req : Request, res : Response):Promise<object> => {
console.log(req.body)
const {name,surname,password,email, role} = req.body; const {name,surname,password,email, role} = req.body;
console.log(req.body)
const displayName = surname+' '+name[0]+'.' const displayName = surname+' '+name[0]+'.'
const user = new User(); const user = new User();
user.name = name; user.name = name;
...@@ -27,16 +43,20 @@ router.post('/', async (req : Request, res : Response):Promise<object> => { ...@@ -27,16 +43,20 @@ router.post('/', async (req : Request, res : Response):Promise<object> => {
user.email = email; user.email = email;
user.role = role; user.role = role;
user.generateToken() user.generateToken()
console.log("user " + user)
await user.save(); await user.save();
console.log("saved")
const userToFront:User|null = await dataSource.manager.findOneBy(User, { const userToFront:User|null = await dataSource.manager.findOneBy(User, {
email: user.email email: user.email
}) })
console.log("userToFront " + userToFront)
return res.send({userToFront}) return res.send({userToFront})
}) })
router.post('/sessions/', async (req : Request, res : Response):Promise<object> => { router.post('/sessions/', async (req : Request, res : Response):Promise<object> => {
const {email, password} = req.body; const {email, password} = req.body;
console.log("email" + email, "password" + password )
const user = await dataSource const user = await dataSource
.createQueryBuilder() .createQueryBuilder()
.select("user") .select("user")
...@@ -46,6 +66,7 @@ router.post('/sessions/', async (req : Request, res : Response):Promise<object> ...@@ -46,6 +66,7 @@ router.post('/sessions/', async (req : Request, res : Response):Promise<object>
.getOne() .getOne()
if(!user) return res.status(404).send({Message:'user not found'}) if(!user) return res.status(404).send({Message:'user not found'})
const isMatch:boolean = await user.checkPassword(password); const isMatch:boolean = await user.checkPassword(password);
console.log("123")
if (!isMatch) return res.status(400).send({ if (!isMatch) return res.status(400).send({
error: "Wrong Password" error: "Wrong Password"
}) })
......
...@@ -6,6 +6,7 @@ import MyTasks from './containers/MyTasks/MyTasks'; ...@@ -6,6 +6,7 @@ import MyTasks from './containers/MyTasks/MyTasks';
import Login from './containers/Login/Login'; import Login from './containers/Login/Login';
import Register from './containers/Register/Register'; import Register from './containers/Register/Register';
import MonthCalendar from './containers/MonthCalendar/MonthCalendar'; import MonthCalendar from './containers/MonthCalendar/MonthCalendar';
import ForgottenPassword from "./containers/ForgottenPassword/ForgottenPassword";
const ProtectedRoute = ({isAllowed, roles, redirectUrl, children}) => { const ProtectedRoute = ({isAllowed, roles, redirectUrl, children}) => {
const user = useSelector(state => state.users?.user); const user = useSelector(state => state.users?.user);
...@@ -95,6 +96,7 @@ const App = () => { ...@@ -95,6 +96,7 @@ const App = () => {
}/> }/>
<Route path={"/sign-in"} element={<Login/>}/> <Route path={"/sign-in"} element={<Login/>}/>
<Route path={"/forgottenpassword"} element={<ForgottenPassword/>}/>
<Route path='*' element={<h1>404</h1>}/> <Route path='*' element={<h1>404</h1>}/>
</Route> </Route>
</Routes> </Routes>
......
import { Button, Grid} from "@mui/material";
import { NavLink } from "react-router-dom";
import FormElement from "../UI/Form/FormElement/FormElement";
const ResetPasswordForm = ({ state, onChange, onSubmit, getFieldError, buttonText }) => {
return <form onSubmit={onSubmit}>
<Grid container spacing={2}>
<FormElement
onChange={onChange}
name="email"
label="Enter your email address"
state={state}
error={getFieldError?.("email")}
/>
</Grid>
<Button
sx={{ mt: "15px" }}
type="submit"
fullWidth
variant="contained"
color="primary"
>
{buttonText}
</Button>
</form>
}
export default ResetPasswordForm;
\ No newline at end of file
import { Button, Grid} from "@mui/material"; import { Button, Grid} from "@mui/material";
// import { NavLink } from "react-router-dom"; import { NavLink } from "react-router-dom";
import FormElement from "../UI/Form/FormElement/FormElement"; import FormElement from "../UI/Form/FormElement/FormElement";
const UserForm = ({ state, onChange, onSubmit, getFieldError, buttonText, resetPassword }) => { const UserForm = ({ state, onChange, onSubmit, getFieldError, buttonText, resetPassword }) => {
...@@ -30,17 +30,17 @@ const UserForm = ({ state, onChange, onSubmit, getFieldError, buttonText, resetP ...@@ -30,17 +30,17 @@ const UserForm = ({ state, onChange, onSubmit, getFieldError, buttonText, resetP
> >
{buttonText} {buttonText}
</Button> </Button>
{/* <Button <Button
component={NavLink} component={NavLink}
to={"/forgottenpassword"} to={"/forgottenpassword"}
sx={{ mt: "15px" }} sx={{ mt: "15px", color: "red" }}
type="submit" type="submit"
fullWidth fullWidth
variant="contained" variant="contained"
color="primary" color="inherit"
> >
{resetPassword} {resetPassword}
</Button> */} </Button>
</form> </form>
} }
......
...@@ -25,13 +25,13 @@ const UserRegistrationForm = ({ state, onChange, onSubmit, getFieldError, button ...@@ -25,13 +25,13 @@ const UserRegistrationForm = ({ state, onChange, onSubmit, getFieldError, button
state={state} state={state}
error={getFieldError?.("email")} error={getFieldError?.("email")}
/> />
<FormElement {/* <FormElement
onChange={onChange} onChange={onChange}
name="number" name="number"
label="Number" label="Number"
state={state} state={state}
error={getFieldError?.("number")} error={getFieldError?.("number")}
/> /> */}
<FormElement <FormElement
onChange={onChange} onChange={onChange}
name="password" name="password"
......
// import { useState } from "react"; import { useState } from "react";
// import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
// import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
// import Loader from "../../components/UI/Loader/Loader"; import Loader from "../../components/UI/Loader/Loader";
// import UserForm from "../../components/UserForm/UserForm"; import { loginUser } from "../../store/actions/usersActions";
// import { loginUser } from "../../store/actions/usersActions"; import PersonIcon from '@mui/icons-material/Person';
// import PersonIcon from '@mui/icons-material/Person'; import styled from "@emotion/styled";
// import styled from "@emotion/styled"; import { Alert, Avatar, Container, Typography } from "@mui/material";
// import { Alert, Avatar, Container, Typography } from "@mui/material"; import ResetPasswordForm from "../../components/UserForm/ResetPasswordForm";
// const StyledContainer = styled(Container)` const StyledContainer = styled(Container)`
// padding-top: 30px; padding-top: 30px;
// padding-bottom: 30px; padding-bottom: 30px;
// box-shadow: 0 18px 30px 0 rgba(0, 0, 0, 0.6); box-shadow: 0 18px 30px 0 rgba(0, 0, 0, 0.6);
// border-radius: 6px; border-radius: 6px;
// `; `;
// const StyledTitle = styled(Typography)` const StyledTitle = styled(Typography)`
// text-align: center; text-align: center;
// font-size: 30px; font-size: 30px;
// margin-bottom: 30px; margin-bottom: 30px;
// `; `;
// const ForgottenPassword = () => { const ForgottenPassword = () => {
// const [state, setState] = useState({ const [state, setState] = useState({
// email: '', email: '',
// redirectUrl: 'http://localhost:3000/passwordreset' redirectUrl: 'http://localhost:3000/passwordreset'
// }); });
// const dispatch = useDispatch(); const dispatch = useDispatch();
// const { loginError, loading } = useSelector(state => state.users); const { loginError, loading } = useSelector(state => state.users);
// console.log(loginError) console.log(loginError)
// const navigate = useNavigate("/") const navigate = useNavigate("/")
// const inputChangeHandler = (e) => { const inputChangeHandler = (e) => {
// const { name, value } = e.target; const { name, value } = e.target;
// setState((prevState) => { setState((prevState) => {
// return { return {
// ...prevState, ...prevState,
// [name]: value [name]: value
// } }
// }); });
// }; };
// const submitHandler = async (e) => { const submitHandler = async (e) => {
// e.preventDefault(); e.preventDefault();
// await dispatch(loginUser(state, navigate)); await dispatch(loginUser(state, navigate));
// }; };
// return <> return <>
// <StyledContainer component={"section"} maxWidth={"xs"}> <StyledContainer component={"section"} maxWidth={"xs"}>
// {!!loginError && <Alert color="error">{loginError}</Alert>} {!!loginError && <Alert color="error">{loginError}</Alert>}
// <Avatar sx={{ m: "0 auto 30px" }}> <Avatar sx={{ m: "0 auto 30px" }}>
// <PersonIcon /> <PersonIcon />
// </Avatar> </Avatar>
// <StyledTitle variant={"h1"}> <StyledTitle variant={"h1"}>
// Password Reset Password Reset
// </StyledTitle> </StyledTitle>
// <UserForm <ResetPasswordForm
// onSubmit={submitHandler} onSubmit={submitHandler}
// state={state} state={state}
// onChange={inputChangeHandler} onChange={inputChangeHandler}
// buttonText={"Sign In"} buttonText={"Submit"}
// resetPassword={"Forgot your password?"} resetPassword={"Forgot your password?"}
// /> />
// </StyledContainer> </StyledContainer>
// <Loader loading={loading} /> <Loader loading={loading} />
// </> </>
// }; };
// export default ForgottenPassword; export default ForgottenPassword;
\ No newline at end of file \ No newline at end of file
...@@ -62,7 +62,7 @@ const Login = () => { ...@@ -62,7 +62,7 @@ const Login = () => {
state={state} state={state}
onChange={inputChangeHandler} onChange={inputChangeHandler}
buttonText={"Sign In"} buttonText={"Sign In"}
// resetPassword={"Forgot your password?"} resetPassword={"Forgot your password?"}
/> />
</StyledContainer> </StyledContainer>
<Loader loading={loading} /> <Loader loading={loading} />
......
...@@ -26,7 +26,7 @@ const Register = () => { ...@@ -26,7 +26,7 @@ const Register = () => {
name: '', name: '',
surname: "", surname: "",
email: "", email: "",
number: "", // number: "",
password: '', password: '',
// avatar: "", // avatar: "",
}); });
...@@ -62,9 +62,10 @@ const Register = () => { ...@@ -62,9 +62,10 @@ const Register = () => {
const formData = new FormData(); const formData = new FormData();
Object.keys(state).forEach(key => { Object.keys(state).forEach(key => {
formData.append(key, state[key]); formData.append(key, state[key]);
console.log("key " + key + "state " + state[key])
}) })
await dispatch(registerUser(formData, navigate)); await dispatch(registerUser(formData, navigate));
await dispatch(loginUser(state, navigate)) // dispatch(loginUser(state, navigate))
}; };
const getFieldError = (fieldname) => { const getFieldError = (fieldname) => {
......
...@@ -18,6 +18,7 @@ export const registerUser = (userData, navigate) => { ...@@ -18,6 +18,7 @@ export const registerUser = (userData, navigate) => {
return async (dispatch) => { return async (dispatch) => {
dispatch(registerUserRequest()); dispatch(registerUserRequest());
try { try {
console.log("register " + userData)
const response = await axios.post("/users", userData); const response = await axios.post("/users", userData);
dispatch(registerUserSuccess()) dispatch(registerUserSuccess())
navigate("/") navigate("/")
...@@ -49,7 +50,25 @@ const logoutUserFailure = (error) => { ...@@ -49,7 +50,25 @@ const logoutUserFailure = (error) => {
export const loginUser = (userData, navigate) => { export const loginUser = (userData, navigate) => {
return async (dispatch) => { return async (dispatch) => {
try { try {
console.log(userData)
const response = await axios.post("users/sessions", userData); const response = await axios.post("users/sessions", userData);
console.log(response)
dispatch(loginUserSuccess(response.data.user));
navigate("/")
} catch (e) {
dispatch(loginUserFailure(e?.response?.data?.err))
}
}
}
export const forgottenPassword = (userData, navigate) => {
return async (dispatch) => {
try {
console.log(userData)
const response = await axios.post("users/requestPasswordReset", userData);
// if (userData.email === response.data.email) {
// }
dispatch(loginUserSuccess(response.data)); dispatch(loginUserSuccess(response.data));
navigate("/") navigate("/")
} catch (e) { } catch (e) {
......
import { REGISTER_USER_REQUEST, REGISTER_USER_SUCCESS, REGISTER_USER_FAILURE, LOGIN_USER_SUCCESS, LOGIN_USER_FAILURE, LOGOUT_USER_SUCCESS } from "../actionTypes/actionTypes"; import { REGISTER_USER_REQUEST, REGISTER_USER_SUCCESS, REGISTER_USER_FAILURE, LOGIN_USER_SUCCESS, LOGIN_USER_FAILURE, LOGOUT_USER_SUCCESS } from "../actionTypes/actionTypes";
const initialState = { const initialState = {
user: { user: null,
name: 'Ivan',
surname: 'Petrov',
email: 'test@gmail.com',
role: 'superuser'
},
registerError: null, registerError: null,
loginError: null, loginError: null,
loading: false loading: false
...@@ -17,12 +12,15 @@ const usersReducer = (state = initialState, action) => { ...@@ -17,12 +12,15 @@ const usersReducer = (state = initialState, action) => {
case REGISTER_USER_REQUEST: case REGISTER_USER_REQUEST:
return {...state, loading: true}; return {...state, loading: true};
case REGISTER_USER_SUCCESS: case REGISTER_USER_SUCCESS:
console.log("register.user " + action)
return {...state, loading: false}; return {...state, loading: false};
case REGISTER_USER_FAILURE: case REGISTER_USER_FAILURE:
return {...state, loading: false, registerError: action.error}; return {...state, loading: false, registerError: action.error};
case LOGIN_USER_SUCCESS: case LOGIN_USER_SUCCESS:
console.log("action.user " + action)
return {...state, user: action.user}; return {...state, user: action.user};
case LOGIN_USER_FAILURE: case LOGIN_USER_FAILURE:
console.log("action.error" + action.error)
return {...state, loginError: action.error}; return {...state, loginError: action.error};
case LOGOUT_USER_SUCCESS: case LOGOUT_USER_SUCCESS:
return {...state, user: null}; return {...state, user: null};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment