feat: emp login,register,invite accept ant reject
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
23a87480b7
commit
5f97c96f07
67 changed files with 3558 additions and 238 deletions
291
Cargo.lock
generated
291
Cargo.lock
generated
|
@ -1,6 +1,6 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "actix-codec"
|
name = "actix-codec"
|
||||||
|
@ -81,7 +81,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb"
|
checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -216,7 +216,7 @@ dependencies = [
|
||||||
"actix-router",
|
"actix-router",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -348,9 +348,9 @@ checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.88"
|
version = "1.0.89"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356"
|
checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "argon2-creds"
|
name = "argon2-creds"
|
||||||
|
@ -371,9 +371,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arrayref"
|
name = "arrayref"
|
||||||
version = "0.3.8"
|
version = "0.3.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a"
|
checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arrayvec"
|
name = "arrayvec"
|
||||||
|
@ -383,13 +383,13 @@ checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-trait"
|
name = "async-trait"
|
||||||
version = "0.1.82"
|
version = "0.1.83"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1"
|
checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -409,9 +409,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.3.0"
|
version = "1.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
|
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "backtrace"
|
name = "backtrace"
|
||||||
|
@ -526,9 +526,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.7.1"
|
version = "1.7.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50"
|
checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytestring"
|
name = "bytestring"
|
||||||
|
@ -541,9 +541,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.1.18"
|
version = "1.1.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476"
|
checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jobserver",
|
"jobserver",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -841,7 +841,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -889,7 +889,7 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"strsim 0.11.1",
|
"strsim 0.11.1",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -911,7 +911,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling_core 0.20.10",
|
"darling_core 0.20.10",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -943,7 +943,7 @@ checksum = "74ef43543e701c01ad77d3a5922755c6a1d71b22d942cb8042be4994b380caff"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -985,7 +985,7 @@ dependencies = [
|
||||||
"darling 0.20.10",
|
"darling 0.20.10",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1005,7 +1005,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4abae7035bf79b9877b779505d8cf3749285b80c43941eda66604841889451dc"
|
checksum = "4abae7035bf79b9877b779505d8cf3749285b80c43941eda66604841889451dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_builder_core 0.20.1",
|
"derive_builder_core 0.20.1",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1018,7 +1018,7 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"rustc_version",
|
"rustc_version",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1038,7 +1038,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1068,7 +1068,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1210,9 +1210,9 @@ checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flate2"
|
name = "flate2"
|
||||||
version = "1.0.33"
|
version = "1.0.34"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253"
|
checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"miniz_oxide",
|
"miniz_oxide",
|
||||||
|
@ -1342,7 +1342,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1492,6 +1492,12 @@ dependencies = [
|
||||||
"allocator-api2",
|
"allocator-api2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.15.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashlink"
|
name = "hashlink"
|
||||||
version = "0.8.4"
|
version = "0.8.4"
|
||||||
|
@ -1616,9 +1622,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "httparse"
|
name = "httparse"
|
||||||
version = "1.9.4"
|
version = "1.9.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9"
|
checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "httpdate"
|
name = "httpdate"
|
||||||
|
@ -1676,7 +1682,7 @@ dependencies = [
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls",
|
"tokio-rustls",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
"webpki-roots 0.26.5",
|
"webpki-roots 0.26.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1697,9 +1703,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hyper-util"
|
name = "hyper-util"
|
||||||
version = "0.1.8"
|
version = "0.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba"
|
checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
|
@ -1710,16 +1716,15 @@ dependencies = [
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"socket2",
|
"socket2",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower",
|
|
||||||
"tower-service",
|
"tower-service",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iana-time-zone"
|
name = "iana-time-zone"
|
||||||
version = "0.1.60"
|
version = "0.1.61"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
|
checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_system_properties",
|
"android_system_properties",
|
||||||
"core-foundation-sys",
|
"core-foundation-sys",
|
||||||
|
@ -1853,7 +1858,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1924,12 +1929,12 @@ checksum = "206ca75c9c03ba3d4ace2460e57b189f39f43de612c2f85836e65c929701bb2d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "2.5.0"
|
version = "2.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5"
|
checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"equivalent",
|
"equivalent",
|
||||||
"hashbrown 0.14.5",
|
"hashbrown 0.15.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2054,7 +2059,7 @@ dependencies = [
|
||||||
"quoted_printable",
|
"quoted_printable",
|
||||||
"rsa",
|
"rsa",
|
||||||
"rustls 0.23.13",
|
"rustls 0.23.13",
|
||||||
"rustls-pemfile 2.1.3",
|
"rustls-pemfile 2.2.0",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"sha2",
|
"sha2",
|
||||||
"socket2",
|
"socket2",
|
||||||
|
@ -2063,14 +2068,14 @@ dependencies = [
|
||||||
"tokio-rustls",
|
"tokio-rustls",
|
||||||
"tracing",
|
"tracing",
|
||||||
"url",
|
"url",
|
||||||
"webpki-roots 0.26.5",
|
"webpki-roots 0.26.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.158"
|
version = "0.2.159"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
|
checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libm"
|
name = "libm"
|
||||||
|
@ -2201,7 +2206,7 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"structmeta",
|
"structmeta",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2294,14 +2299,14 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mutually_exclusive_features"
|
name = "mutually_exclusive_features"
|
||||||
version = "0.0.3"
|
version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6d02c0b00610773bb7fc61d85e13d86c7858cbdf00e1a120bfc41bc055dbaa0e"
|
checksum = "e94e1e6445d314f972ff7395df2de295fe51b71821694f0b0e1e79c4f12c8577"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "native-tls"
|
name = "native-tls"
|
||||||
|
@ -2400,9 +2405,12 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.19.0"
|
version = "1.20.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1"
|
||||||
|
dependencies = [
|
||||||
|
"portable-atomic",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "opaque-debug"
|
name = "opaque-debug"
|
||||||
|
@ -2433,7 +2441,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2525,9 +2533,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pest"
|
name = "pest"
|
||||||
version = "2.7.12"
|
version = "2.7.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c73c26c01b8c87956cea613c907c9d6ecffd8d18a2a5908e5de0adfaa185cea"
|
checksum = "fdbef9d1d47087a895abd220ed25eb4ad973a5e26f6a4367b038c25e28dfc2d9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
@ -2536,9 +2544,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pest_derive"
|
name = "pest_derive"
|
||||||
version = "2.7.12"
|
version = "2.7.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "664d22978e2815783adbdd2c588b455b1bd625299ce36b2a99881ac9627e6d8d"
|
checksum = "4d3a6e3394ec80feb3b6393c725571754c6188490265c61aaf260810d6b95aa0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pest",
|
"pest",
|
||||||
"pest_generator",
|
"pest_generator",
|
||||||
|
@ -2546,22 +2554,22 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pest_generator"
|
name = "pest_generator"
|
||||||
version = "2.7.12"
|
version = "2.7.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a2d5487022d5d33f4c30d91c22afa240ce2a644e87fe08caad974d4eab6badbe"
|
checksum = "94429506bde1ca69d1b5601962c73f4172ab4726571a59ea95931218cb0e930e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pest",
|
"pest",
|
||||||
"pest_meta",
|
"pest_meta",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pest_meta"
|
name = "pest_meta"
|
||||||
version = "2.7.12"
|
version = "2.7.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0091754bbd0ea592c4deb3a122ce8ecbb0753b738aa82bc055fcc2eccc8d8174"
|
checksum = "ac8a071862e93690b6e34e9a5fb8e33ff3734473ac0245b27232222c4906a33f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"pest",
|
"pest",
|
||||||
|
@ -2661,7 +2669,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2699,9 +2707,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pkg-config"
|
name = "pkg-config"
|
||||||
version = "0.3.30"
|
version = "0.3.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
|
checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "polyval"
|
name = "polyval"
|
||||||
|
@ -2715,6 +2723,12 @@ dependencies = [
|
||||||
"universal-hash",
|
"universal-hash",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "portable-atomic"
|
||||||
|
version = "1.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "postgres-es"
|
name = "postgres-es"
|
||||||
version = "0.4.11"
|
version = "0.4.11"
|
||||||
|
@ -2924,18 +2938,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.5.4"
|
version = "0.5.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853"
|
checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.10.6"
|
version = "1.11.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
|
checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
|
@ -2945,9 +2959,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-automata"
|
name = "regex-automata"
|
||||||
version = "0.4.7"
|
version = "0.4.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
|
checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
|
@ -2962,15 +2976,15 @@ checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-syntax"
|
name = "regex-syntax"
|
||||||
version = "0.8.4"
|
version = "0.8.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
|
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reqwest"
|
name = "reqwest"
|
||||||
version = "0.12.7"
|
version = "0.12.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63"
|
checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
@ -2995,7 +3009,7 @@ dependencies = [
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"quinn",
|
"quinn",
|
||||||
"rustls 0.23.13",
|
"rustls 0.23.13",
|
||||||
"rustls-pemfile 2.1.3",
|
"rustls-pemfile 2.2.0",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
@ -3012,7 +3026,7 @@ dependencies = [
|
||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
"wasm-streams",
|
"wasm-streams",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
"webpki-roots 0.26.5",
|
"webpki-roots 0.26.6",
|
||||||
"windows-registry",
|
"windows-registry",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3094,7 +3108,7 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"rust-embed-utils",
|
"rust-embed-utils",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3190,19 +3204,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls-pemfile"
|
name = "rustls-pemfile"
|
||||||
version = "2.1.3"
|
version = "2.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425"
|
checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.22.1",
|
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls-pki-types"
|
name = "rustls-pki-types"
|
||||||
version = "1.8.0"
|
version = "1.9.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0"
|
checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls-webpki"
|
name = "rustls-webpki"
|
||||||
|
@ -3280,9 +3293,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "security-framework-sys"
|
name = "security-framework-sys"
|
||||||
version = "2.11.1"
|
version = "2.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf"
|
checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"core-foundation-sys",
|
"core-foundation-sys",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -3311,7 +3324,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3328,9 +3341,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_spanned"
|
name = "serde_spanned"
|
||||||
version = "0.6.7"
|
version = "0.6.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d"
|
checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
@ -3746,7 +3759,7 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"structmeta-derive",
|
"structmeta-derive",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3757,7 +3770,7 @@ checksum = "152a0b65a590ff6c3da95cabe2353ee04e6167c896b28e3b14478c2636c922fc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3779,9 +3792,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.77"
|
version = "2.0.79"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed"
|
checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -3805,7 +3818,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3831,9 +3844,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tempfile"
|
name = "tempfile"
|
||||||
version = "3.12.0"
|
version = "3.13.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64"
|
checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"fastrand",
|
"fastrand",
|
||||||
|
@ -3892,22 +3905,22 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.63"
|
version = "1.0.64"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
|
checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "1.0.63"
|
version = "1.0.64"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
|
checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4001,7 +4014,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4072,9 +4085,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_edit"
|
name = "toml_edit"
|
||||||
version = "0.22.20"
|
version = "0.22.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d"
|
checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -4083,27 +4096,6 @@ dependencies = [
|
||||||
"winnow",
|
"winnow",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tower"
|
|
||||||
version = "0.4.13"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
|
|
||||||
dependencies = [
|
|
||||||
"futures-core",
|
|
||||||
"futures-util",
|
|
||||||
"pin-project",
|
|
||||||
"pin-project-lite",
|
|
||||||
"tokio",
|
|
||||||
"tower-layer",
|
|
||||||
"tower-service",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tower-layer"
|
|
||||||
version = "0.3.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tower-service"
|
name = "tower-service"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
|
@ -4124,9 +4116,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-actix-web"
|
name = "tracing-actix-web"
|
||||||
version = "0.7.12"
|
version = "0.7.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "284586dc201db407be8c9d721abad1b3a6dacbbce5cccecd4fd15a37db95ab0d"
|
checksum = "15bc0cd5f72e837e310f4d978a90abf202a7f7d8ef3272246bae381d0086d3bf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-web",
|
"actix-web",
|
||||||
"mutually_exclusive_features",
|
"mutually_exclusive_features",
|
||||||
|
@ -4143,7 +4135,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4169,9 +4161,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ucd-trie"
|
name = "ucd-trie"
|
||||||
version = "0.1.6"
|
version = "0.1.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"
|
checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unic-char-property"
|
name = "unic-char-property"
|
||||||
|
@ -4237,30 +4229,30 @@ checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-normalization"
|
name = "unicode-normalization"
|
||||||
version = "0.1.23"
|
version = "0.1.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5"
|
checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tinyvec",
|
"tinyvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-properties"
|
name = "unicode-properties"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "52ea75f83c0137a9b98608359a5f1af8144876eb67bcb1ce837368e906a9f524"
|
checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-segmentation"
|
name = "unicode-segmentation"
|
||||||
version = "1.11.0"
|
version = "1.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
|
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
version = "0.2.5"
|
version = "0.2.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a"
|
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode_categories"
|
name = "unicode_categories"
|
||||||
|
@ -4390,7 +4382,7 @@ dependencies = [
|
||||||
"proc-macro-error",
|
"proc-macro-error",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4426,7 +4418,6 @@ dependencies = [
|
||||||
"postgres-es",
|
"postgres-es",
|
||||||
"pretty_env_logger",
|
"pretty_env_logger",
|
||||||
"rand",
|
"rand",
|
||||||
"reqwest",
|
|
||||||
"rust-embed",
|
"rust-embed",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
@ -4505,7 +4496,7 @@ dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -4539,7 +4530,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
"wasm-bindgen-backend",
|
"wasm-bindgen-backend",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
@ -4552,9 +4543,9 @@ checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-streams"
|
name = "wasm-streams"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129"
|
checksum = "4e072d4e72f700fb3443d8fe94a39315df013eef1104903cdb0a2abd322bbecd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
|
@ -4581,9 +4572,9 @@ checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webpki-roots"
|
name = "webpki-roots"
|
||||||
version = "0.26.5"
|
version = "0.26.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a"
|
checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
]
|
]
|
||||||
|
@ -4604,7 +4595,7 @@ version = "0.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4796,9 +4787,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winnow"
|
name = "winnow"
|
||||||
version = "0.6.18"
|
version = "0.6.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f"
|
checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
@ -4855,7 +4846,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
"synstructure",
|
"synstructure",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -4877,7 +4868,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4897,7 +4888,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
"synstructure",
|
"synstructure",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -4926,7 +4917,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -39,5 +39,5 @@ uuid = { version = "1.10.0", features = ["v4", "serde"] }
|
||||||
validator = { version = "0.18.1", features = ["derive"] }
|
validator = { version = "0.18.1", features = ["derive"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
reqwest = { version = "0.12.4", features = ["json"] }
|
#reqwest = { version = "0.12.4", features = ["json"] }
|
||||||
mailpit_client = { path = "./mailpit_client" }
|
mailpit_client = { path = "./mailpit_client" }
|
||||||
|
|
30
devenv.lock
30
devenv.lock
|
@ -3,11 +3,11 @@
|
||||||
"devenv": {
|
"devenv": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "src/modules",
|
"dir": "src/modules",
|
||||||
"lastModified": 1726063457,
|
"lastModified": 1727779147,
|
||||||
"owner": "cachix",
|
"owner": "cachix",
|
||||||
"repo": "devenv",
|
"repo": "devenv",
|
||||||
"rev": "39bf6ce569103c9390d37322daa59468c31b3ce7",
|
"rev": "eb86c60fc04a8be6a544b2647cc0ca8dc611533e",
|
||||||
"treeHash": "839747a1cb35ba6d5b36cce9a739ab2ba5e4a5d4",
|
"treeHash": "b34fbd0d9f58e9356ab63dce000e333f0d64d564",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -25,11 +25,11 @@
|
||||||
"rust-analyzer-src": "rust-analyzer-src"
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726116637,
|
"lastModified": 1727850840,
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "fenix",
|
"repo": "fenix",
|
||||||
"rev": "96a04a213838c5001619ad57400c5a176fa040b1",
|
"rev": "b85dddb88366113db4616a64925a8b2a23854f98",
|
||||||
"treeHash": "af83666a28d8bb6aa6d4c0e5f4a2a9c6c158e272",
|
"treeHash": "402bc80d9b07e5f6772ddec24b57da6d136f996a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -93,11 +93,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs-stable": {
|
"nixpkgs-stable": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1725930920,
|
"lastModified": 1727672256,
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "44a71ff39c182edaf25a7ace5c9454e7cba2c658",
|
"rev": "1719f27dd95fd4206afb9cec9f415b539978827e",
|
||||||
"treeHash": "56e93544112b7bb7aa0c3093d537295683ef9148",
|
"treeHash": "f8f2200987d4957a54683e8ff3c9bfae24dca6b9",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -117,11 +117,11 @@
|
||||||
"nixpkgs-stable": "nixpkgs-stable"
|
"nixpkgs-stable": "nixpkgs-stable"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1725513492,
|
"lastModified": 1727854478,
|
||||||
"owner": "cachix",
|
"owner": "cachix",
|
||||||
"repo": "pre-commit-hooks.nix",
|
"repo": "pre-commit-hooks.nix",
|
||||||
"rev": "7570de7b9b504cfe92025dd1be797bf546f66528",
|
"rev": "5f58871c9657b5fc0a7f65670fe2ba99c26c1d79",
|
||||||
"treeHash": "4b46d77870afecd8f642541cb4f4927326343b59",
|
"treeHash": "9bd8fa1bb0d757e1eb29a1eb0d8da485b57b1b31",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -141,11 +141,11 @@
|
||||||
"rust-analyzer-src": {
|
"rust-analyzer-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726144767,
|
"lastModified": 1727778987,
|
||||||
"owner": "rust-lang",
|
"owner": "rust-lang",
|
||||||
"repo": "rust-analyzer",
|
"repo": "rust-analyzer",
|
||||||
"rev": "fd243cd0fbad8297e7a3c86f18aa5f0a110bb85f",
|
"rev": "e1a76671af2fbc74c84c18ba18fcda5e653d7531",
|
||||||
"treeHash": "8fbbce6f1b56bbcbe27c9af7f6298582c22ae34d",
|
"treeHash": "0c89aea03913ed5c40e21fb4b2c6f7aa6cb54085",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
pkgs.podman
|
pkgs.podman
|
||||||
pkgs.podman-compose
|
pkgs.podman-compose
|
||||||
pkgs.openssl
|
pkgs.openssl
|
||||||
pkgs.openssl
|
|
||||||
pkgs.direnv
|
pkgs.direnv
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
37
rustc-ice-2024-10-01T11_03_41-594641.txt
Normal file
37
rustc-ice-2024-10-01T11_03_41-594641.txt
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
thread 'rustc' panicked at compiler/rustc_middle/src/query/on_disk_cache.rs:736:21:
|
||||||
|
Failed to convert DefPathHash DefPathHash(Fingerprint(9597590199268592635, 17791879502897349522))
|
||||||
|
stack backtrace:
|
||||||
|
0: 0x7fbfbb48d025 - std::backtrace::Backtrace::create::hbc256ff4bc983c0b
|
||||||
|
1: 0x7fbfb9c8c865 - std::backtrace::Backtrace::force_capture::h1ebb6042c5b424a8
|
||||||
|
2: 0x7fbfb8db2217 - std[11ac8361619e45fd]::panicking::update_hook::<alloc[1ed43557cf619c2]::boxed::Box<rustc_driver_impl[8c32a9dec5e4d0f0]::install_ice_hook::{closure#0}>>::{closure#0}
|
||||||
|
3: 0x7fbfb9ca3ee8 - std::panicking::rust_panic_with_hook::ha6cfc51100acb1ab
|
||||||
|
4: 0x7fbfb9ca3cb7 - std::panicking::begin_panic_handler::{{closure}}::he56e1efe5ba67ce1
|
||||||
|
5: 0x7fbfb9ca1699 - std::sys::backtrace::__rust_end_short_backtrace::hcc7bf1345a5f7ae3
|
||||||
|
6: 0x7fbfb9ca3984 - rust_begin_unwind
|
||||||
|
7: 0x7fbfb6ad55c3 - core::panicking::panic_fmt::h146c2ef4416c8c7b
|
||||||
|
8: 0x7fbfba61abc5 - <rustc_middle[62c17eb200ed25ef]::query::on_disk_cache::CacheDecoder as rustc_span[e2902ef3f031f316]::SpanDecoder>::decode_span
|
||||||
|
9: 0x7fbfba94bc1c - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::DefIdCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||||
|
10: 0x7fbfba94929a - rustc_query_impl[2b1ee272ecafb82c]::query_impl::def_span::get_query_incr::__rust_end_short_backtrace
|
||||||
|
11: 0x7fbfbaa190c0 - rustc_middle[62c17eb200ed25ef]::query::plumbing::query_get_at::<rustc_query_system[4b3461eb5f3eee8]::query::caches::DefIdCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 8usize]>>>
|
||||||
|
12: 0x7fbfbacaaf7d - <rustc_hir_analysis[198913e0276c9380]::coherence::inherent_impls_overlap::InherentOverlapChecker>::check_for_duplicate_items_in_impl
|
||||||
|
13: 0x7fbfbb39e280 - rustc_hir_analysis[198913e0276c9380]::coherence::inherent_impls_overlap::crate_inherent_impls_overlap_check
|
||||||
|
14: 0x7fbfbb39dc6d - rustc_query_impl[2b1ee272ecafb82c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2b1ee272ecafb82c]::query_impl::crate_inherent_impls_overlap_check::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>
|
||||||
|
15: 0x7fbfbb39d1fd - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::SingleCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||||
|
16: 0x7fbfbb39c867 - rustc_query_impl[2b1ee272ecafb82c]::query_impl::crate_inherent_impls_overlap_check::get_query_incr::__rust_end_short_backtrace
|
||||||
|
17: 0x7fbfba5bb6f3 - rustc_hir_analysis[198913e0276c9380]::check_crate
|
||||||
|
18: 0x7fbfba5b1351 - rustc_interface[d7e86b952eb641e5]::passes::run_required_analyses
|
||||||
|
19: 0x7fbfbb1bac1e - rustc_interface[d7e86b952eb641e5]::passes::analysis
|
||||||
|
20: 0x7fbfbb1babf1 - rustc_query_impl[2b1ee272ecafb82c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2b1ee272ecafb82c]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>
|
||||||
|
21: 0x7fbfbb39cecd - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::SingleCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||||
|
22: 0x7fbfbb39cb7a - rustc_query_impl[2b1ee272ecafb82c]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
|
||||||
|
23: 0x7fbfbb1b30bc - rustc_interface[d7e86b952eb641e5]::interface::run_compiler::<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}
|
||||||
|
24: 0x7fbfbb2c0504 - std[11ac8361619e45fd]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_with_globals<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_pool_with_globals<rustc_interface[d7e86b952eb641e5]::interface::run_compiler<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>
|
||||||
|
25: 0x7fbfbb2c0b70 - <<std[11ac8361619e45fd]::thread::Builder>::spawn_unchecked_<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_with_globals<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_pool_with_globals<rustc_interface[d7e86b952eb641e5]::interface::run_compiler<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#1} as core[dcc560a250502550]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
|
||||||
|
26: 0x7fbfbb2c0f6b - std::sys::pal::unix::thread::Thread::new::thread_start::h1921d0f3a7850262
|
||||||
|
27: 0x7fbfbcbf8272 - start_thread
|
||||||
|
28: 0x7fbfbcc73dcc - clone3
|
||||||
|
29: 0x0 - <unknown>
|
||||||
|
|
||||||
|
|
||||||
|
rustc version: 1.83.0-nightly (0ee7cb5e3 2024-09-10)
|
||||||
|
platform: x86_64-unknown-linux-gnu
|
37
rustc-ice-2024-10-01T11_03_53-595154.txt
Normal file
37
rustc-ice-2024-10-01T11_03_53-595154.txt
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
thread 'rustc' panicked at compiler/rustc_middle/src/query/on_disk_cache.rs:736:21:
|
||||||
|
Failed to convert DefPathHash DefPathHash(Fingerprint(9597590199268592635, 17791879502897349522))
|
||||||
|
stack backtrace:
|
||||||
|
0: 0x77c2cca8d025 - std::backtrace::Backtrace::create::hbc256ff4bc983c0b
|
||||||
|
1: 0x77c2cb28c865 - std::backtrace::Backtrace::force_capture::h1ebb6042c5b424a8
|
||||||
|
2: 0x77c2ca3b2217 - std[11ac8361619e45fd]::panicking::update_hook::<alloc[1ed43557cf619c2]::boxed::Box<rustc_driver_impl[8c32a9dec5e4d0f0]::install_ice_hook::{closure#0}>>::{closure#0}
|
||||||
|
3: 0x77c2cb2a3ee8 - std::panicking::rust_panic_with_hook::ha6cfc51100acb1ab
|
||||||
|
4: 0x77c2cb2a3cb7 - std::panicking::begin_panic_handler::{{closure}}::he56e1efe5ba67ce1
|
||||||
|
5: 0x77c2cb2a1699 - std::sys::backtrace::__rust_end_short_backtrace::hcc7bf1345a5f7ae3
|
||||||
|
6: 0x77c2cb2a3984 - rust_begin_unwind
|
||||||
|
7: 0x77c2c80d55c3 - core::panicking::panic_fmt::h146c2ef4416c8c7b
|
||||||
|
8: 0x77c2cbc1abc5 - <rustc_middle[62c17eb200ed25ef]::query::on_disk_cache::CacheDecoder as rustc_span[e2902ef3f031f316]::SpanDecoder>::decode_span
|
||||||
|
9: 0x77c2cbf4bc1c - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::DefIdCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||||
|
10: 0x77c2cbf4929a - rustc_query_impl[2b1ee272ecafb82c]::query_impl::def_span::get_query_incr::__rust_end_short_backtrace
|
||||||
|
11: 0x77c2cc0190c0 - rustc_middle[62c17eb200ed25ef]::query::plumbing::query_get_at::<rustc_query_system[4b3461eb5f3eee8]::query::caches::DefIdCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 8usize]>>>
|
||||||
|
12: 0x77c2cc2aaf7d - <rustc_hir_analysis[198913e0276c9380]::coherence::inherent_impls_overlap::InherentOverlapChecker>::check_for_duplicate_items_in_impl
|
||||||
|
13: 0x77c2cc99e280 - rustc_hir_analysis[198913e0276c9380]::coherence::inherent_impls_overlap::crate_inherent_impls_overlap_check
|
||||||
|
14: 0x77c2cc99dc6d - rustc_query_impl[2b1ee272ecafb82c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2b1ee272ecafb82c]::query_impl::crate_inherent_impls_overlap_check::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>
|
||||||
|
15: 0x77c2cc99d1fd - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::SingleCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||||
|
16: 0x77c2cc99c867 - rustc_query_impl[2b1ee272ecafb82c]::query_impl::crate_inherent_impls_overlap_check::get_query_incr::__rust_end_short_backtrace
|
||||||
|
17: 0x77c2cbbbb6f3 - rustc_hir_analysis[198913e0276c9380]::check_crate
|
||||||
|
18: 0x77c2cbbb1351 - rustc_interface[d7e86b952eb641e5]::passes::run_required_analyses
|
||||||
|
19: 0x77c2cc7bac1e - rustc_interface[d7e86b952eb641e5]::passes::analysis
|
||||||
|
20: 0x77c2cc7babf1 - rustc_query_impl[2b1ee272ecafb82c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2b1ee272ecafb82c]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>
|
||||||
|
21: 0x77c2cc99cecd - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::SingleCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||||
|
22: 0x77c2cc99cb7a - rustc_query_impl[2b1ee272ecafb82c]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
|
||||||
|
23: 0x77c2cc7b30bc - rustc_interface[d7e86b952eb641e5]::interface::run_compiler::<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}
|
||||||
|
24: 0x77c2cc8c0504 - std[11ac8361619e45fd]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_with_globals<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_pool_with_globals<rustc_interface[d7e86b952eb641e5]::interface::run_compiler<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>
|
||||||
|
25: 0x77c2cc8c0b70 - <<std[11ac8361619e45fd]::thread::Builder>::spawn_unchecked_<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_with_globals<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_pool_with_globals<rustc_interface[d7e86b952eb641e5]::interface::run_compiler<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#1} as core[dcc560a250502550]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
|
||||||
|
26: 0x77c2cc8c0f6b - std::sys::pal::unix::thread::Thread::new::thread_start::h1921d0f3a7850262
|
||||||
|
27: 0x77c2ce089272 - start_thread
|
||||||
|
28: 0x77c2ce104dcc - clone3
|
||||||
|
29: 0x0 - <unknown>
|
||||||
|
|
||||||
|
|
||||||
|
rustc version: 1.83.0-nightly (0ee7cb5e3 2024-09-10)
|
||||||
|
platform: x86_64-unknown-linux-gnu
|
37
rustc-ice-2024-10-01T11_04_04-595752.txt
Normal file
37
rustc-ice-2024-10-01T11_04_04-595752.txt
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
thread 'rustc' panicked at compiler/rustc_middle/src/query/on_disk_cache.rs:736:21:
|
||||||
|
Failed to convert DefPathHash DefPathHash(Fingerprint(9597590199268592635, 17791879502897349522))
|
||||||
|
stack backtrace:
|
||||||
|
0: 0x704a8948d025 - std::backtrace::Backtrace::create::hbc256ff4bc983c0b
|
||||||
|
1: 0x704a87c8c865 - std::backtrace::Backtrace::force_capture::h1ebb6042c5b424a8
|
||||||
|
2: 0x704a86db2217 - std[11ac8361619e45fd]::panicking::update_hook::<alloc[1ed43557cf619c2]::boxed::Box<rustc_driver_impl[8c32a9dec5e4d0f0]::install_ice_hook::{closure#0}>>::{closure#0}
|
||||||
|
3: 0x704a87ca3ee8 - std::panicking::rust_panic_with_hook::ha6cfc51100acb1ab
|
||||||
|
4: 0x704a87ca3cb7 - std::panicking::begin_panic_handler::{{closure}}::he56e1efe5ba67ce1
|
||||||
|
5: 0x704a87ca1699 - std::sys::backtrace::__rust_end_short_backtrace::hcc7bf1345a5f7ae3
|
||||||
|
6: 0x704a87ca3984 - rust_begin_unwind
|
||||||
|
7: 0x704a84ad55c3 - core::panicking::panic_fmt::h146c2ef4416c8c7b
|
||||||
|
8: 0x704a8861abc5 - <rustc_middle[62c17eb200ed25ef]::query::on_disk_cache::CacheDecoder as rustc_span[e2902ef3f031f316]::SpanDecoder>::decode_span
|
||||||
|
9: 0x704a8894bc1c - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::DefIdCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||||
|
10: 0x704a8894929a - rustc_query_impl[2b1ee272ecafb82c]::query_impl::def_span::get_query_incr::__rust_end_short_backtrace
|
||||||
|
11: 0x704a88a190c0 - rustc_middle[62c17eb200ed25ef]::query::plumbing::query_get_at::<rustc_query_system[4b3461eb5f3eee8]::query::caches::DefIdCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 8usize]>>>
|
||||||
|
12: 0x704a88caaf7d - <rustc_hir_analysis[198913e0276c9380]::coherence::inherent_impls_overlap::InherentOverlapChecker>::check_for_duplicate_items_in_impl
|
||||||
|
13: 0x704a8939e280 - rustc_hir_analysis[198913e0276c9380]::coherence::inherent_impls_overlap::crate_inherent_impls_overlap_check
|
||||||
|
14: 0x704a8939dc6d - rustc_query_impl[2b1ee272ecafb82c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2b1ee272ecafb82c]::query_impl::crate_inherent_impls_overlap_check::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>
|
||||||
|
15: 0x704a8939d1fd - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::SingleCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||||
|
16: 0x704a8939c867 - rustc_query_impl[2b1ee272ecafb82c]::query_impl::crate_inherent_impls_overlap_check::get_query_incr::__rust_end_short_backtrace
|
||||||
|
17: 0x704a885bb6f3 - rustc_hir_analysis[198913e0276c9380]::check_crate
|
||||||
|
18: 0x704a885b1351 - rustc_interface[d7e86b952eb641e5]::passes::run_required_analyses
|
||||||
|
19: 0x704a891bac1e - rustc_interface[d7e86b952eb641e5]::passes::analysis
|
||||||
|
20: 0x704a891babf1 - rustc_query_impl[2b1ee272ecafb82c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2b1ee272ecafb82c]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>
|
||||||
|
21: 0x704a8939cecd - rustc_query_system[4b3461eb5f3eee8]::query::plumbing::try_execute_query::<rustc_query_impl[2b1ee272ecafb82c]::DynamicConfig<rustc_query_system[4b3461eb5f3eee8]::query::caches::SingleCache<rustc_middle[62c17eb200ed25ef]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2b1ee272ecafb82c]::plumbing::QueryCtxt, true>
|
||||||
|
22: 0x704a8939cb7a - rustc_query_impl[2b1ee272ecafb82c]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
|
||||||
|
23: 0x704a891b30bc - rustc_interface[d7e86b952eb641e5]::interface::run_compiler::<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}
|
||||||
|
24: 0x704a892c0504 - std[11ac8361619e45fd]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_with_globals<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_pool_with_globals<rustc_interface[d7e86b952eb641e5]::interface::run_compiler<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>
|
||||||
|
25: 0x704a892c0b70 - <<std[11ac8361619e45fd]::thread::Builder>::spawn_unchecked_<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_with_globals<rustc_interface[d7e86b952eb641e5]::util::run_in_thread_pool_with_globals<rustc_interface[d7e86b952eb641e5]::interface::run_compiler<core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>, rustc_driver_impl[8c32a9dec5e4d0f0]::run_compiler::{closure#0}>::{closure#1}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dcc560a250502550]::result::Result<(), rustc_span[e2902ef3f031f316]::ErrorGuaranteed>>::{closure#1} as core[dcc560a250502550]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
|
||||||
|
26: 0x704a892c0f6b - std::sys::pal::unix::thread::Thread::new::thread_start::h1921d0f3a7850262
|
||||||
|
27: 0x704a8ac0b272 - start_thread
|
||||||
|
28: 0x704a8ac86dcc - clone3
|
||||||
|
29: 0x0 - <unknown>
|
||||||
|
|
||||||
|
|
||||||
|
rustc version: 1.83.0-nightly (0ee7cb5e3 2024-09-10)
|
||||||
|
platform: x86_64-unknown-linux-gnu
|
|
@ -29,7 +29,7 @@ impl GetVerificationSecretOutDBPort for DBOutPostgresAdapter {
|
||||||
)
|
)
|
||||||
.fetch_one(&self.pool)
|
.fetch_one(&self.pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| map_row_not_found_err(e, OutDBPortError::VerificationOTPSecretNotFound))?;
|
.map_err(|e| map_row_not_found_err(e, OutDBPortError::VerificationOTPNotFound))?;
|
||||||
Ok(res.secret)
|
Ok(res.secret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
db.get_verification_secret(&user_id).await.err(),
|
db.get_verification_secret(&user_id).await.err(),
|
||||||
Some(OutDBPortError::VerificationOTPSecretNotFound)
|
Some(OutDBPortError::VerificationOTPNotFound)
|
||||||
);
|
);
|
||||||
|
|
||||||
let create_msg = CreateSecretMsgBuilder::default()
|
let create_msg = CreateSecretMsgBuilder::default()
|
||||||
|
|
|
@ -11,7 +11,7 @@ use uuid::Uuid;
|
||||||
|
|
||||||
use super::errors::*;
|
use super::errors::*;
|
||||||
use super::DBOutPostgresAdapter;
|
use super::DBOutPostgresAdapter;
|
||||||
use crate::identity::application::services::events::UserEvent;
|
use crate::identity::application::services::events::IdentityEvent;
|
||||||
use crate::identity::domain::aggregate::User;
|
use crate::identity::domain::aggregate::User;
|
||||||
use crate::utils::parse_aggregate_id::parse_aggregate_id;
|
use crate::utils::parse_aggregate_id::parse_aggregate_id;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ pub struct UserView {
|
||||||
impl View<User> for UserView {
|
impl View<User> for UserView {
|
||||||
fn update(&mut self, event: &EventEnvelope<User>) {
|
fn update(&mut self, event: &EventEnvelope<User>) {
|
||||||
match &event.payload {
|
match &event.payload {
|
||||||
UserEvent::UserRegistered(val) => {
|
IdentityEvent::UserRegistered(val) => {
|
||||||
self.email = val.email().into();
|
self.email = val.email().into();
|
||||||
self.hashed_password = val.hashed_password().into();
|
self.hashed_password = val.hashed_password().into();
|
||||||
self.is_admin = val.is_admin().to_owned();
|
self.is_admin = val.is_admin().to_owned();
|
||||||
|
@ -47,19 +47,20 @@ impl View<User> for UserView {
|
||||||
self.last_name = val.last_name().into();
|
self.last_name = val.last_name().into();
|
||||||
self.user_id = *val.user_id();
|
self.user_id = *val.user_id();
|
||||||
}
|
}
|
||||||
UserEvent::UserDeleted => self.deleted = true,
|
IdentityEvent::UserDeleted => self.deleted = true,
|
||||||
UserEvent::Loggedin(_) => (),
|
IdentityEvent::Loggedin(_) => (),
|
||||||
UserEvent::PasswordUpdated(_) => (),
|
IdentityEvent::PasswordUpdated(_) => (),
|
||||||
UserEvent::EmailUpdated(val) => {
|
IdentityEvent::EmailUpdated(val) => {
|
||||||
self.email = val.new_email().into();
|
self.email = val.new_email().into();
|
||||||
}
|
}
|
||||||
UserEvent::UserVerified => {
|
IdentityEvent::UserVerified => {
|
||||||
self.is_verified = true;
|
self.is_verified = true;
|
||||||
}
|
}
|
||||||
UserEvent::UserPromotedToAdmin(_) => {
|
IdentityEvent::UserPromotedToAdmin(_) => {
|
||||||
self.is_admin = true;
|
self.is_admin = true;
|
||||||
}
|
}
|
||||||
UserEvent::VerificationEmailResent => (),
|
IdentityEvent::VerificationEmailResent => (),
|
||||||
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,10 +170,9 @@ impl ViewRepository<UserView, User> for DBOutPostgresAdapter {
|
||||||
"UPDATE
|
"UPDATE
|
||||||
user_query
|
user_query
|
||||||
SET
|
SET
|
||||||
user_id = $1, version = $2, first_name = $3, email = $4,
|
version = $1, first_name = $2, email = $3,
|
||||||
hashed_password = $5, is_admin = $6, is_verified = $7, deleted = $8,
|
hashed_password = $4, is_admin = $5, is_verified = $6, deleted = $7,
|
||||||
last_name=$9;",
|
last_name=$8;",
|
||||||
view.user_id,
|
|
||||||
version,
|
version,
|
||||||
view.first_name,
|
view.first_name,
|
||||||
view.email,
|
view.email,
|
||||||
|
|
49
src/identity/application/port/output/db/create_login_otp.rs
Normal file
49
src/identity/application/port/output/db/create_login_otp.rs
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Builder)]
|
||||||
|
pub struct CreateOTPMsg {
|
||||||
|
pub otp: usize,
|
||||||
|
pub emp_id: Uuid,
|
||||||
|
}
|
||||||
|
pub const REGISTRATION_OTP_PURPOSE: &str = "account_login";
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait CreateLoginOTPOutDBPort: Send + Sync {
|
||||||
|
async fn create_login_otp(&self, msg: CreateOTPMsg) -> OutDBPortResult<()>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type CreateLoginOTPOutDBPortObj = std::sync::Arc<dyn CreateLoginOTPOutDBPort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_create_login_otp_db_port(times: Option<usize>) -> CreateLoginOTPOutDBPortObj {
|
||||||
|
let mut m = MockCreateLoginOTPOutDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_create_login_otp()
|
||||||
|
.times(times)
|
||||||
|
.returning(|_| Ok(()));
|
||||||
|
} else {
|
||||||
|
m.expect_create_login_otp().returning(|_| Ok(()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Builder)]
|
||||||
|
pub struct CreateOTPMsg {
|
||||||
|
pub otp: usize,
|
||||||
|
pub emp_id: Uuid,
|
||||||
|
}
|
||||||
|
pub const REGISTRATION_OTP_PURPOSE: &str = "account_validation";
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait CreateVerificationOTPOutDBPort: Send + Sync {
|
||||||
|
async fn create_verification_otp(&self, msg: CreateOTPMsg) -> OutDBPortResult<()>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type CreateVerificationOTPOutDBPortObj = std::sync::Arc<dyn CreateVerificationOTPOutDBPort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_create_verification_otp_db_port(
|
||||||
|
times: Option<usize>,
|
||||||
|
) -> CreateVerificationOTPOutDBPortObj {
|
||||||
|
let mut m = MockCreateVerificationOTPOutDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_create_verification_otp()
|
||||||
|
.times(times)
|
||||||
|
.returning(|_| Ok(()));
|
||||||
|
} else {
|
||||||
|
m.expect_create_verification_otp().returning(|_| Ok(()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
46
src/identity/application/port/output/db/delete_login_otp.rs
Normal file
46
src/identity/application/port/output/db/delete_login_otp.rs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
pub use super::create_login_otp::REGISTRATION_OTP_PURPOSE;
|
||||||
|
use super::errors::*;
|
||||||
|
use super::phone_exists;
|
||||||
|
use crate::identity::domain::employee_aggregate::*;
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait DeleteLoginOTPOutDBPort: Send + Sync {
|
||||||
|
async fn delete_login_otp(&self, otp: usize, phone_exists: &PhoneNumber)
|
||||||
|
-> OutDBPortResult<()>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type DeleteLoginOTPOutDBPortObj = std::sync::Arc<dyn DeleteLoginOTPOutDBPort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_delete_login_otp_db_port(times: Option<usize>) -> DeleteLoginOTPOutDBPortObj {
|
||||||
|
let mut m = MockDeleteLoginOTPOutDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_delete_login_otp()
|
||||||
|
.times(times)
|
||||||
|
.returning(|_, _| Ok(()));
|
||||||
|
} else {
|
||||||
|
m.expect_delete_login_otp().returning(|_, _| Ok(()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
use super::verification_otp_exists::*;
|
||||||
|
use crate::identity::domain::employee_aggregate::*;
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait DeleteVerificationOTPOutDBPort: Send + Sync {
|
||||||
|
async fn delete_verification_otp(
|
||||||
|
&self,
|
||||||
|
otp: usize,
|
||||||
|
phone_number: &PhoneNumber,
|
||||||
|
) -> OutDBPortResult<()>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type DeleteVerificationOTPOutDBPortObj = std::sync::Arc<dyn DeleteVerificationOTPOutDBPort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_delete_verification_otp_db_port(
|
||||||
|
times: Option<usize>,
|
||||||
|
) -> DeleteVerificationOTPOutDBPortObj {
|
||||||
|
let mut m = MockDeleteVerificationOTPOutDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_delete_verification_otp()
|
||||||
|
.times(times)
|
||||||
|
.returning(|_, _| Ok(()));
|
||||||
|
} else {
|
||||||
|
m.expect_delete_verification_otp().returning(|_, _| Ok(()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
43
src/identity/application/port/output/db/emp_id_exists.rs
Normal file
43
src/identity/application/port/output/db/emp_id_exists.rs
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait EmpIDExistsOutDBPort: Send + Sync {
|
||||||
|
async fn emp_id_exists(&self, emp_id: &Uuid) -> OutDBPortResult<bool>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type EmpIDExistsOutDBPortObj = std::sync::Arc<dyn EmpIDExistsOutDBPort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_emp_id_exists_db_port(
|
||||||
|
times: Option<usize>,
|
||||||
|
returning: bool,
|
||||||
|
) -> EmpIDExistsOutDBPortObj {
|
||||||
|
let mut m = MockEmpIDExistsOutDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_emp_id_exists()
|
||||||
|
.times(times)
|
||||||
|
.returning(move |_| Ok(returning));
|
||||||
|
} else {
|
||||||
|
m.expect_emp_id_exists().returning(move |_| Ok(returning));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,5 +11,6 @@ pub type OutDBPortResult<V> = Result<V, OutDBPortError>;
|
||||||
pub enum OutDBPortError {
|
pub enum OutDBPortError {
|
||||||
InternalError,
|
InternalError,
|
||||||
DuplicateVerificationOTPSecret,
|
DuplicateVerificationOTPSecret,
|
||||||
VerificationOTPSecretNotFound,
|
VerificationSecretNotFound,
|
||||||
|
VerificationOTPNotFound,
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
use crate::identity::domain::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait GetEmpIDFromPhoneNumberOutDBPort: Send + Sync {
|
||||||
|
async fn get_emp_id_from_phone_number(&self, phone: &PhoneNumber) -> OutDBPortResult<Uuid>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type GetEmpIDFromPhoneNumberOutDBPortObj = std::sync::Arc<dyn GetEmpIDFromPhoneNumberOutDBPort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use crate::utils::uuid::tests::UUID;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_get_emp_id_from_phone_number_db_port(
|
||||||
|
times: Option<usize>,
|
||||||
|
) -> GetEmpIDFromPhoneNumberOutDBPortObj {
|
||||||
|
let mut m = MockGetEmpIDFromPhoneNumberOutDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_get_emp_id_from_phone_number()
|
||||||
|
.times(times)
|
||||||
|
.returning(move |_| Ok(UUID));
|
||||||
|
} else {
|
||||||
|
m.expect_get_emp_id_from_phone_number()
|
||||||
|
.returning(move |_| Ok(UUID));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
58
src/identity/application/port/output/db/get_invite.rs
Normal file
58
src/identity/application/port/output/db/get_invite.rs
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
use crate::identity::domain::employee_aggregate::*;
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait GetInviteOutDBPort: Send + Sync {
|
||||||
|
async fn get_invite(&self, invitge_id: Uuid) -> OutDBPortResult<Option<Uuid>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type GetInviteOutDBPortObj = std::sync::Arc<dyn GetInviteOutDBPort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use crate::utils::uuid::tests::*;
|
||||||
|
|
||||||
|
pub fn mock_get_invite_db_port_returns_none(times: Option<usize>) -> GetInviteOutDBPortObj {
|
||||||
|
let mut m = MockGetInviteOutDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_get_invite()
|
||||||
|
.times(times)
|
||||||
|
.returning(move |_| Ok(None));
|
||||||
|
} else {
|
||||||
|
m.expect_get_invite().returning(move |_| Ok(None));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mock_get_invite_db_port(times: Option<usize>) -> GetInviteOutDBPortObj {
|
||||||
|
let mut m = MockGetInviteOutDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_get_invite()
|
||||||
|
.times(times)
|
||||||
|
.returning(move |_| Ok(Some(UUID)));
|
||||||
|
} else {
|
||||||
|
m.expect_get_invite().returning(move |_| Ok(Some(UUID)));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
59
src/identity/application/port/output/db/get_login_otp.rs
Normal file
59
src/identity/application/port/output/db/get_login_otp.rs
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
pub use super::create_login_otp::REGISTRATION_OTP_PURPOSE;
|
||||||
|
use super::errors::*;
|
||||||
|
use crate::identity::domain::employee_aggregate::*;
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait GetLoginOTPOutDBPort: Send + Sync {
|
||||||
|
async fn get_login_otp(&self, phone_number: &PhoneNumber) -> OutDBPortResult<Option<usize>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type GetLoginOTPOutDBPortObj = std::sync::Arc<dyn GetLoginOTPOutDBPort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_get_login_otp_db_port_returns_none(
|
||||||
|
times: Option<usize>,
|
||||||
|
) -> GetLoginOTPOutDBPortObj {
|
||||||
|
let mut m = MockGetLoginOTPOutDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_get_login_otp()
|
||||||
|
.times(times)
|
||||||
|
.returning(move |_| Ok(None));
|
||||||
|
} else {
|
||||||
|
m.expect_get_login_otp().returning(move |_| Ok(None));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mock_get_login_otp_db_port(times: Option<usize>) -> GetLoginOTPOutDBPortObj {
|
||||||
|
let mut m = MockGetLoginOTPOutDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_get_login_otp()
|
||||||
|
.times(times)
|
||||||
|
.returning(move |_| Ok(Some(0)));
|
||||||
|
} else {
|
||||||
|
m.expect_get_login_otp().returning(move |_| Ok(Some(0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
pub use super::create_verification_otp::REGISTRATION_OTP_PURPOSE;
|
||||||
|
use super::errors::*;
|
||||||
|
use crate::identity::domain::employee_aggregate::*;
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait GetVerificationOTPOutDBPort: Send + Sync {
|
||||||
|
async fn get_verification_otp(
|
||||||
|
&self,
|
||||||
|
phone_number: &PhoneNumber,
|
||||||
|
) -> OutDBPortResult<Option<usize>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type GetVerificationOTPOutDBPortObj = std::sync::Arc<dyn GetVerificationOTPOutDBPort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_get_verification_otp_db_port_returns_none(
|
||||||
|
times: Option<usize>,
|
||||||
|
) -> GetVerificationOTPOutDBPortObj {
|
||||||
|
let mut m = MockGetVerificationOTPOutDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_get_verification_otp()
|
||||||
|
.times(times)
|
||||||
|
.returning(move |_| Ok(None));
|
||||||
|
} else {
|
||||||
|
m.expect_get_verification_otp().returning(move |_| Ok(None));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mock_get_verification_otp_db_port(
|
||||||
|
times: Option<usize>,
|
||||||
|
) -> GetVerificationOTPOutDBPortObj {
|
||||||
|
let mut m = MockGetVerificationOTPOutDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_get_verification_otp()
|
||||||
|
.times(times)
|
||||||
|
.returning(move |_| Ok(Some(0)));
|
||||||
|
} else {
|
||||||
|
m.expect_get_verification_otp()
|
||||||
|
.returning(move |_| Ok(Some(0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
53
src/identity/application/port/output/db/invite_id_exists.rs
Normal file
53
src/identity/application/port/output/db/invite_id_exists.rs
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait InviteIDExistsDBPort: Send + Sync {
|
||||||
|
async fn invite_id_exists(&self, invite_id: &Uuid) -> OutDBPortResult<bool>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type InviteIDExistsDBPortObj = std::sync::Arc<dyn InviteIDExistsDBPort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_invite_id_exists_db_port_false(times: Option<usize>) -> InviteIDExistsDBPortObj {
|
||||||
|
let mut m = MockInviteIDExistsDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_invite_id_exists()
|
||||||
|
.times(times)
|
||||||
|
.returning(|_| Ok(false));
|
||||||
|
} else {
|
||||||
|
m.expect_invite_id_exists().returning(|_| Ok(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mock_invite_id_exists_db_port_true(times: Option<usize>) -> InviteIDExistsDBPortObj {
|
||||||
|
let mut m = MockInviteIDExistsDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_invite_id_exists()
|
||||||
|
.times(times)
|
||||||
|
.returning(|_| Ok(true));
|
||||||
|
} else {
|
||||||
|
m.expect_invite_id_exists().returning(|_| Ok(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
52
src/identity/application/port/output/db/login_otp_exists.rs
Normal file
52
src/identity/application/port/output/db/login_otp_exists.rs
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
pub use super::create_login_otp::REGISTRATION_OTP_PURPOSE;
|
||||||
|
use super::errors::*;
|
||||||
|
use crate::identity::domain::employee_aggregate::*;
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait LoginOTPExistsOutDBPort: Send + Sync {
|
||||||
|
async fn login_otp_exists(
|
||||||
|
&self,
|
||||||
|
otp: usize,
|
||||||
|
phone_number: &PhoneNumber,
|
||||||
|
) -> OutDBPortResult<bool>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type LoginOTPExistsOutDBPortObj = std::sync::Arc<dyn LoginOTPExistsOutDBPort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_login_otp_exists_db_port(
|
||||||
|
times: Option<usize>,
|
||||||
|
returning: bool,
|
||||||
|
) -> LoginOTPExistsOutDBPortObj {
|
||||||
|
let mut m = MockLoginOTPExistsOutDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_login_otp_exists()
|
||||||
|
.times(times)
|
||||||
|
.returning(move |_, _| Ok(returning));
|
||||||
|
} else {
|
||||||
|
m.expect_login_otp_exists()
|
||||||
|
.returning(move |_, _| Ok(returning));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,10 +2,23 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
pub mod create_login_otp;
|
||||||
|
pub mod create_verification_otp;
|
||||||
pub mod create_verification_secret;
|
pub mod create_verification_secret;
|
||||||
|
pub mod delete_login_otp;
|
||||||
|
pub mod delete_verification_otp;
|
||||||
pub mod delete_verification_secret;
|
pub mod delete_verification_secret;
|
||||||
pub mod email_exists;
|
pub mod email_exists;
|
||||||
|
pub mod emp_id_exists;
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
|
pub mod get_emp_id_from_phone_number;
|
||||||
|
pub mod get_invite;
|
||||||
|
pub mod get_login_otp;
|
||||||
|
pub mod get_verification_otp;
|
||||||
pub mod get_verification_secret;
|
pub mod get_verification_secret;
|
||||||
|
pub mod invite_id_exists;
|
||||||
|
pub mod phone_exists;
|
||||||
|
pub mod store_id_exists;
|
||||||
pub mod user_id_exists;
|
pub mod user_id_exists;
|
||||||
|
pub mod verification_otp_exists;
|
||||||
pub mod verification_secret_exists;
|
pub mod verification_secret_exists;
|
||||||
|
|
44
src/identity/application/port/output/db/phone_exists.rs
Normal file
44
src/identity/application/port/output/db/phone_exists.rs
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
use crate::identity::domain::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait PhoneNumberExistsOutDBPort: Send + Sync {
|
||||||
|
async fn phone_exists(&self, phone: &PhoneNumber) -> OutDBPortResult<bool>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type PhoneNumberExistsOutDBPortObj = std::sync::Arc<dyn PhoneNumberExistsOutDBPort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_phone_exists_db_port(
|
||||||
|
times: Option<usize>,
|
||||||
|
returning: bool,
|
||||||
|
) -> PhoneNumberExistsOutDBPortObj {
|
||||||
|
let mut m = MockPhoneNumberExistsOutDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_phone_exists()
|
||||||
|
.times(times)
|
||||||
|
.returning(move |_| Ok(returning));
|
||||||
|
} else {
|
||||||
|
m.expect_phone_exists().returning(move |_| Ok(returning));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
53
src/identity/application/port/output/db/store_id_exists.rs
Normal file
53
src/identity/application/port/output/db/store_id_exists.rs
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait StoreIDExistsDBPort: Send + Sync {
|
||||||
|
async fn store_id_exists(&self, store_id: &Uuid) -> OutDBPortResult<bool>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type StoreIDExistsDBPortObj = std::sync::Arc<dyn StoreIDExistsDBPort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_store_id_exists_db_port_false(times: Option<usize>) -> StoreIDExistsDBPortObj {
|
||||||
|
let mut m = MockStoreIDExistsDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_store_id_exists()
|
||||||
|
.times(times)
|
||||||
|
.returning(|_| Ok(false));
|
||||||
|
} else {
|
||||||
|
m.expect_store_id_exists().returning(|_| Ok(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mock_store_id_exists_db_port_true(times: Option<usize>) -> StoreIDExistsDBPortObj {
|
||||||
|
let mut m = MockStoreIDExistsDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_store_id_exists()
|
||||||
|
.times(times)
|
||||||
|
.returning(|_| Ok(true));
|
||||||
|
} else {
|
||||||
|
m.expect_store_id_exists().returning(|_| Ok(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
pub use super::create_verification_otp::REGISTRATION_OTP_PURPOSE;
|
||||||
|
use super::errors::*;
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Builder)]
|
||||||
|
pub struct VerifyOTPExistsMsg {
|
||||||
|
pub otp: String,
|
||||||
|
pub emp_id: Uuid,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait VerificationOTPExistsOutDBPort: Send + Sync {
|
||||||
|
async fn verification_otp_exists(&self, msg: &VerifyOTPExistsMsg) -> OutDBPortResult<bool>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type VerificationOTPExistsOutDBPortObj = std::sync::Arc<dyn VerificationOTPExistsOutDBPort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_verification_otp_exists_db_port(
|
||||||
|
times: Option<usize>,
|
||||||
|
returning: bool,
|
||||||
|
) -> VerificationOTPExistsOutDBPortObj {
|
||||||
|
let mut m = MockVerificationOTPExistsOutDBPort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_verification_otp_exists()
|
||||||
|
.times(times)
|
||||||
|
.returning(move |_| Ok(returning));
|
||||||
|
} else {
|
||||||
|
m.expect_verification_otp_exists()
|
||||||
|
.returning(move |_| Ok(returning));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,3 +4,4 @@
|
||||||
|
|
||||||
pub mod db;
|
pub mod db;
|
||||||
pub mod mailer;
|
pub mod mailer;
|
||||||
|
pub mod phone;
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
use crate::identity::domain::employee_aggregate::PhoneNumber;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait AccountLoginOTPOutPhonePort: Send + Sync {
|
||||||
|
async fn account_login_otp(&self, to: &PhoneNumber, otp: usize) -> OutPhonePortResult<()>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type AccountLoginOTPOutPhonePortObj = std::sync::Arc<dyn AccountLoginOTPOutPhonePort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_account_login_otp_phone_port(
|
||||||
|
times: Option<usize>,
|
||||||
|
) -> AccountLoginOTPOutPhonePortObj {
|
||||||
|
let mut m = MockAccountLoginOTPOutPhonePort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_account_login_otp()
|
||||||
|
.times(times)
|
||||||
|
.returning(|_, _| Ok(()));
|
||||||
|
} else {
|
||||||
|
m.expect_account_login_otp().returning(|_, _| Ok(()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
use crate::identity::domain::employee_aggregate::PhoneNumber;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub use tests::*;
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait AccountValidationOTPOutPhonePort: Send + Sync {
|
||||||
|
async fn account_validation_otp(&self, to: &PhoneNumber, otp: usize) -> OutPhonePortResult<()>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type AccountValidationOTPOutPhonePortObj = std::sync::Arc<dyn AccountValidationOTPOutPhonePort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_account_validation_otp_phone_port(
|
||||||
|
times: Option<usize>,
|
||||||
|
) -> AccountValidationOTPOutPhonePortObj {
|
||||||
|
let mut m = MockAccountValidationOTPOutPhonePort::new();
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_account_validation_otp()
|
||||||
|
.times(times)
|
||||||
|
.returning(|_, _| Ok(()));
|
||||||
|
} else {
|
||||||
|
m.expect_account_validation_otp().returning(|_, _| Ok(()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
13
src/identity/application/port/output/phone/errors.rs
Normal file
13
src/identity/application/port/output/phone/errors.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_more::Display;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
pub type OutPhonePortResult<V> = Result<V, OutPhonePortError>;
|
||||||
|
|
||||||
|
#[derive(Debug, Display, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
|
pub enum OutPhonePortError {
|
||||||
|
InternalError,
|
||||||
|
}
|
7
src/identity/application/port/output/phone/mod.rs
Normal file
7
src/identity/application/port/output/phone/mod.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
pub mod account_login_otp;
|
||||||
|
pub mod account_validation_otp;
|
||||||
|
pub mod errors;
|
|
@ -0,0 +1,128 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use derive_builder::Builder;
|
||||||
|
|
||||||
|
use crate::identity::application::port::output::db::{emp_id_exists::*, get_invite::*};
|
||||||
|
use crate::identity::domain::{accept_invite_command::*, invite_accepted_event::*};
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait EmployeeAcceptInviteUseCase: Send + Sync {
|
||||||
|
async fn accept_invite(&self, cmd: AcceptInviteCommand) -> IdentityResult<InviteAcceptedEvent>;
|
||||||
|
async fn reject_invite(&self, cmd: AcceptInviteCommand) -> IdentityResult<InviteAcceptedEvent>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type EmployeeAcceptInviteServiceObj = std::sync::Arc<dyn EmployeeAcceptInviteUseCase>;
|
||||||
|
|
||||||
|
#[derive(Clone, Builder)]
|
||||||
|
pub struct EmployeeAcceptInviteService {
|
||||||
|
db_emp_id_exists_adapter: EmpIDExistsOutDBPortObj,
|
||||||
|
db_get_invite_adapter: GetInviteOutDBPortObj,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl EmployeeAcceptInviteUseCase for EmployeeAcceptInviteService {
|
||||||
|
async fn reject_invite(&self, cmd: AcceptInviteCommand) -> IdentityResult<InviteAcceptedEvent> {
|
||||||
|
todo!("also change input and output types");
|
||||||
|
}
|
||||||
|
async fn accept_invite(&self, cmd: AcceptInviteCommand) -> IdentityResult<InviteAcceptedEvent> {
|
||||||
|
if !self
|
||||||
|
.db_emp_id_exists_adapter
|
||||||
|
.emp_id_exists(cmd.emp_id())
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
return Err(IdentityError::EmployeeNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
let invite = match self
|
||||||
|
.db_get_invite_adapter
|
||||||
|
.get_invite(*cmd.invite_id())
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
None => return Err(IdentityError::InviteNotFound),
|
||||||
|
Some(invite) => invite,
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(InviteAcceptedEventBuilder::default()
|
||||||
|
.emp_id(*cmd.emp_id())
|
||||||
|
.invite_id(*cmd.invite_id())
|
||||||
|
.store_id(invite)
|
||||||
|
.build()
|
||||||
|
.unwrap())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::{tests::bdd::*, utils::uuid::tests::*};
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service() {
|
||||||
|
let s = EmployeeAcceptInviteServiceBuilder::default()
|
||||||
|
.db_emp_id_exists_adapter(mock_emp_id_exists_db_port(IS_CALLED_ONLY_ONCE, true))
|
||||||
|
.db_get_invite_adapter(mock_get_invite_db_port(IS_CALLED_ONLY_ONCE))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = AcceptInviteCommandBuilder::default()
|
||||||
|
.emp_id(UUID)
|
||||||
|
.invite_id(UUID)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let res = s.accept_invite(cmd.clone()).await.unwrap();
|
||||||
|
assert_eq!(*res.emp_id(), UUID);
|
||||||
|
assert_eq!(*res.invite_id(), UUID);
|
||||||
|
assert_eq!(*res.store_id(), UUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_invite_no_exist() {
|
||||||
|
let s = EmployeeAcceptInviteServiceBuilder::default()
|
||||||
|
.db_emp_id_exists_adapter(mock_emp_id_exists_db_port(IS_CALLED_ONLY_ONCE, true))
|
||||||
|
.db_get_invite_adapter(mock_get_invite_db_port_returns_none(IS_CALLED_ONLY_ONCE))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = AcceptInviteCommandBuilder::default()
|
||||||
|
.emp_id(UUID)
|
||||||
|
.invite_id(UUID)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
s.accept_invite(cmd.clone()).await.err(),
|
||||||
|
Some(IdentityError::InviteNotFound)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_emp_no_exist() {
|
||||||
|
let s = EmployeeAcceptInviteServiceBuilder::default()
|
||||||
|
.db_emp_id_exists_adapter(mock_emp_id_exists_db_port(IS_CALLED_ONLY_ONCE, false))
|
||||||
|
.db_get_invite_adapter(mock_get_invite_db_port(IS_NEVER_CALLED))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = AcceptInviteCommandBuilder::default()
|
||||||
|
.emp_id(UUID)
|
||||||
|
.invite_id(UUID)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
s.accept_invite(cmd.clone()).await.err(),
|
||||||
|
Some(IdentityError::EmployeeNotFound)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use derive_builder::Builder;
|
||||||
|
|
||||||
|
use crate::identity::application::port::output::db::{emp_id_exists::*, store_id_exists::*};
|
||||||
|
use crate::identity::domain::{exit_organization_command::*, organization_exited_event::*};
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait EmployeeExitOrganizationUseCase: Send + Sync {
|
||||||
|
async fn exit_organization(
|
||||||
|
&self,
|
||||||
|
cmd: ExitOrganizationCommand,
|
||||||
|
) -> IdentityResult<OrganizationExitedEvent>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type EmployeeExitOrganizationServiceObj = std::sync::Arc<dyn EmployeeExitOrganizationUseCase>;
|
||||||
|
|
||||||
|
#[derive(Clone, Builder)]
|
||||||
|
pub struct EmployeeExitOrganizationService {
|
||||||
|
db_emp_id_exists_adapter: EmpIDExistsOutDBPortObj,
|
||||||
|
db_store_id_exists_adapter: StoreIDExistsDBPortObj,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl EmployeeExitOrganizationUseCase for EmployeeExitOrganizationService {
|
||||||
|
async fn exit_organization(
|
||||||
|
&self,
|
||||||
|
cmd: ExitOrganizationCommand,
|
||||||
|
) -> IdentityResult<OrganizationExitedEvent> {
|
||||||
|
if !self
|
||||||
|
.db_emp_id_exists_adapter
|
||||||
|
.emp_id_exists(cmd.emp_id())
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
return Err(IdentityError::EmployeeNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
if !self
|
||||||
|
.db_store_id_exists_adapter
|
||||||
|
.store_id_exists(cmd.emp_id())
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
return Err(IdentityError::StoreNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(OrganizationExitedEventBuilder::default()
|
||||||
|
.emp_id(*cmd.emp_id())
|
||||||
|
.store_id(*cmd.store_id())
|
||||||
|
.build()
|
||||||
|
.unwrap())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::{tests::bdd::*, utils::uuid::tests::*};
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service() {
|
||||||
|
let s = EmployeeExitOrganizationServiceBuilder::default()
|
||||||
|
.db_emp_id_exists_adapter(mock_emp_id_exists_db_port(IS_CALLED_ONLY_ONCE, true))
|
||||||
|
.db_store_id_exists_adapter(mock_store_id_exists_db_port_true(IS_CALLED_ONLY_ONCE))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = ExitOrganizationCommandBuilder::default()
|
||||||
|
.emp_id(UUID)
|
||||||
|
.store_id(UUID)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let res = s.exit_organization(cmd.clone()).await.unwrap();
|
||||||
|
assert_eq!(*res.emp_id(), UUID);
|
||||||
|
assert_eq!(*res.store_id(), UUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_store_no_exist() {
|
||||||
|
let s = EmployeeExitOrganizationServiceBuilder::default()
|
||||||
|
.db_emp_id_exists_adapter(mock_emp_id_exists_db_port(IS_CALLED_ONLY_ONCE, true))
|
||||||
|
.db_store_id_exists_adapter(mock_store_id_exists_db_port_false(IS_CALLED_ONLY_ONCE))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = ExitOrganizationCommandBuilder::default()
|
||||||
|
.emp_id(UUID)
|
||||||
|
.store_id(UUID)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
s.exit_organization(cmd.clone()).await.err(),
|
||||||
|
Some(IdentityError::StoreNotFound)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_emp_no_exist() {
|
||||||
|
let s = EmployeeExitOrganizationServiceBuilder::default()
|
||||||
|
.db_emp_id_exists_adapter(mock_emp_id_exists_db_port(IS_CALLED_ONLY_ONCE, false))
|
||||||
|
.db_store_id_exists_adapter(mock_store_id_exists_db_port_true(IS_NEVER_CALLED))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = ExitOrganizationCommandBuilder::default()
|
||||||
|
.emp_id(UUID)
|
||||||
|
.store_id(UUID)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
s.exit_organization(cmd.clone()).await.err(),
|
||||||
|
Some(IdentityError::EmployeeNotFound)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
338
src/identity/application/services/employee_login_service.rs
Normal file
338
src/identity/application/services/employee_login_service.rs
Normal file
|
@ -0,0 +1,338 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
|
||||||
|
use crate::identity::application::port::output::{
|
||||||
|
db::{
|
||||||
|
create_login_otp::*, delete_login_otp::*, emp_id_exists::*,
|
||||||
|
get_emp_id_from_phone_number::*, get_login_otp::*, phone_exists::*,
|
||||||
|
},
|
||||||
|
phone::account_login_otp::*,
|
||||||
|
};
|
||||||
|
use crate::identity::domain::{
|
||||||
|
employee_aggregate::*, employee_logged_in_event::*, employee_login_command::*,
|
||||||
|
};
|
||||||
|
use crate::utils::random_number::*;
|
||||||
|
|
||||||
|
use super::employee_register_service::OTP_LEN;
|
||||||
|
use super::errors::*;
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait EmployeeLoginUseCase: Send + Sync {
|
||||||
|
async fn finish_login(
|
||||||
|
&self,
|
||||||
|
cmd: EmployeeFinishLoginCommand,
|
||||||
|
) -> IdentityResult<EmployeeLoggedInEvent>;
|
||||||
|
|
||||||
|
async fn init_login(
|
||||||
|
&self,
|
||||||
|
cmd: EmployeeInitLoginCommand,
|
||||||
|
) -> IdentityResult<EmployeeInitLoggedInEvent>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type EmployeeLoginServiceObj = std::sync::Arc<dyn EmployeeLoginUseCase>;
|
||||||
|
|
||||||
|
#[derive(Clone, Builder)]
|
||||||
|
pub struct EmployeeLoginService {
|
||||||
|
db_phone_exists_adapter: PhoneNumberExistsOutDBPortObj,
|
||||||
|
db_get_emp_id_from_phone_number_adapter: GetEmpIDFromPhoneNumberOutDBPortObj,
|
||||||
|
db_create_login_otp_adapter: CreateLoginOTPOutDBPortObj,
|
||||||
|
db_delete_login_otp: DeleteLoginOTPOutDBPortObj,
|
||||||
|
db_get_login_otp: GetLoginOTPOutDBPortObj,
|
||||||
|
random_number_adapter: GenerateRandomNumberInterfaceObj,
|
||||||
|
phone_login_otp_adapter: AccountLoginOTPOutPhonePortObj,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl EmployeeLoginUseCase for EmployeeLoginService {
|
||||||
|
async fn finish_login(
|
||||||
|
&self,
|
||||||
|
cmd: EmployeeFinishLoginCommand,
|
||||||
|
) -> IdentityResult<EmployeeLoggedInEvent> {
|
||||||
|
match self
|
||||||
|
.db_get_login_otp
|
||||||
|
.get_login_otp(cmd.phone_number())
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
Some(otp) => {
|
||||||
|
if otp == *cmd.otp() {
|
||||||
|
self.db_delete_login_otp
|
||||||
|
.delete_login_otp(*cmd.otp(), cmd.phone_number())
|
||||||
|
.await?;
|
||||||
|
} else {
|
||||||
|
return Err(IdentityError::LoginFailed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => return Err(IdentityError::LoginOTPNotFound),
|
||||||
|
}
|
||||||
|
let emp_id = self
|
||||||
|
.db_get_emp_id_from_phone_number_adapter
|
||||||
|
.get_emp_id_from_phone_number(cmd.phone_number())
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(EmployeeLoggedInEventBuilder::default()
|
||||||
|
.emp_id(emp_id)
|
||||||
|
.build()
|
||||||
|
.unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn init_login(
|
||||||
|
&self,
|
||||||
|
cmd: EmployeeInitLoginCommand,
|
||||||
|
) -> IdentityResult<EmployeeInitLoggedInEvent> {
|
||||||
|
if !self
|
||||||
|
.db_phone_exists_adapter
|
||||||
|
.phone_exists(cmd.phone_number())
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
return Err(IdentityError::PhoneNumberNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
let emp_id = self
|
||||||
|
.db_get_emp_id_from_phone_number_adapter
|
||||||
|
.get_emp_id_from_phone_number(cmd.phone_number())
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let otp = match self
|
||||||
|
.db_get_login_otp
|
||||||
|
.get_login_otp(cmd.phone_number())
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
Some(otp) => otp,
|
||||||
|
None => {
|
||||||
|
let otp = self.random_number_adapter.get_random(OTP_LEN);
|
||||||
|
|
||||||
|
self.db_create_login_otp_adapter
|
||||||
|
.create_login_otp(
|
||||||
|
CreateOTPMsgBuilder::default()
|
||||||
|
.otp(otp.clone())
|
||||||
|
.emp_id(emp_id)
|
||||||
|
.build()
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
otp
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
self.phone_login_otp_adapter
|
||||||
|
.account_login_otp(cmd.phone_number(), otp)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(EmployeeInitLoggedInEventBuilder::default()
|
||||||
|
.emp_id(emp_id)
|
||||||
|
.build()
|
||||||
|
.unwrap())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::{
|
||||||
|
tests::bdd::*,
|
||||||
|
utils::{random_number::tests::mock_generate_random_number, uuid::tests::*},
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
impl EmployeeLoginService {
|
||||||
|
pub fn mock_finish_login(
|
||||||
|
times: Option<usize>,
|
||||||
|
_cmd: EmployeeFinishLoginCommand,
|
||||||
|
) -> EmployeeLoginServiceObj {
|
||||||
|
let res = EmployeeLoggedInEvent::get_event();
|
||||||
|
|
||||||
|
let mut m = MockEmployeeLoginUseCase::default();
|
||||||
|
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_finish_login()
|
||||||
|
.times(times)
|
||||||
|
.returning(move |_| Ok(res.clone()));
|
||||||
|
} else {
|
||||||
|
m.expect_finish_login().returning(move |_| Ok(res.clone()));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sync::Arc::new(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mock_init_login(
|
||||||
|
times: Option<usize>,
|
||||||
|
cmd: EmployeeInitLoginCommand,
|
||||||
|
) -> EmployeeLoginServiceObj {
|
||||||
|
let res = EmployeeInitLoggedInEvent::get_event();
|
||||||
|
|
||||||
|
let mut m = MockEmployeeLoginUseCase::default();
|
||||||
|
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_init_login()
|
||||||
|
.times(times)
|
||||||
|
.returning(move |_| Ok(res.clone()));
|
||||||
|
} else {
|
||||||
|
m.expect_init_login().returning(move |_| Ok(res.clone()));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sync::Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_init_login() {
|
||||||
|
let s = EmployeeLoginServiceBuilder::default()
|
||||||
|
.db_phone_exists_adapter(mock_phone_exists_db_port(IS_CALLED_ONLY_ONCE, true))
|
||||||
|
.db_get_emp_id_from_phone_number_adapter(mock_get_emp_id_from_phone_number_db_port(
|
||||||
|
IS_CALLED_ONLY_ONCE,
|
||||||
|
))
|
||||||
|
.db_create_login_otp_adapter(mock_create_login_otp_db_port(IS_CALLED_ONLY_ONCE))
|
||||||
|
.db_delete_login_otp(mock_delete_login_otp_db_port(IS_NEVER_CALLED))
|
||||||
|
.db_get_login_otp(mock_get_login_otp_db_port_returns_none(IS_CALLED_ONLY_ONCE))
|
||||||
|
.random_number_adapter(mock_generate_random_number(IS_CALLED_ONLY_ONCE, 0))
|
||||||
|
.phone_login_otp_adapter(mock_account_login_otp_phone_port(IS_CALLED_ONLY_ONCE))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = EmployeeInitLoginCommandBuilder::default()
|
||||||
|
.phone_number(PhoneNumber::default())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
let res = s.init_login(cmd.clone()).await.unwrap();
|
||||||
|
assert_eq!(res.emp_id(), &UUID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_init_login_phone_doesnt_exist() {
|
||||||
|
let s = EmployeeLoginServiceBuilder::default()
|
||||||
|
.db_phone_exists_adapter(mock_phone_exists_db_port(IS_CALLED_ONLY_ONCE, false))
|
||||||
|
.db_get_emp_id_from_phone_number_adapter(mock_get_emp_id_from_phone_number_db_port(
|
||||||
|
IS_NEVER_CALLED,
|
||||||
|
))
|
||||||
|
.db_create_login_otp_adapter(mock_create_login_otp_db_port(IS_NEVER_CALLED))
|
||||||
|
.db_delete_login_otp(mock_delete_login_otp_db_port(IS_NEVER_CALLED))
|
||||||
|
.db_get_login_otp(mock_get_login_otp_db_port_returns_none(IS_NEVER_CALLED))
|
||||||
|
.random_number_adapter(mock_generate_random_number(IS_NEVER_CALLED, 0))
|
||||||
|
.phone_login_otp_adapter(mock_account_login_otp_phone_port(IS_NEVER_CALLED))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = EmployeeInitLoginCommandBuilder::default()
|
||||||
|
.phone_number(PhoneNumber::default())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
let res = s.init_login(cmd.clone()).await;
|
||||||
|
assert_eq!(res.err(), Some(IdentityError::PhoneNumberNotFound))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_init_login_otp_exists() {
|
||||||
|
let s = EmployeeLoginServiceBuilder::default()
|
||||||
|
.db_phone_exists_adapter(mock_phone_exists_db_port(IS_CALLED_ONLY_ONCE, true))
|
||||||
|
.db_get_emp_id_from_phone_number_adapter(mock_get_emp_id_from_phone_number_db_port(
|
||||||
|
IS_NEVER_CALLED,
|
||||||
|
))
|
||||||
|
.db_create_login_otp_adapter(mock_create_login_otp_db_port(IS_NEVER_CALLED))
|
||||||
|
.db_delete_login_otp(mock_delete_login_otp_db_port(IS_NEVER_CALLED))
|
||||||
|
.db_get_login_otp(mock_get_login_otp_db_port(IS_CALLED_ONLY_ONCE))
|
||||||
|
.random_number_adapter(mock_generate_random_number(IS_NEVER_CALLED, 0))
|
||||||
|
.phone_login_otp_adapter(mock_account_login_otp_phone_port(IS_CALLED_ONLY_ONCE))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = EmployeeInitLoginCommandBuilder::default()
|
||||||
|
.phone_number(PhoneNumber::default())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
let res = s.init_login(cmd.clone()).await.unwrap();
|
||||||
|
assert_eq!(res.emp_id(), &UUID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_finish_login() {
|
||||||
|
let s = EmployeeLoginServiceBuilder::default()
|
||||||
|
.db_phone_exists_adapter(mock_phone_exists_db_port(IS_NEVER_CALLED, true))
|
||||||
|
.db_get_emp_id_from_phone_number_adapter(mock_get_emp_id_from_phone_number_db_port(
|
||||||
|
IS_CALLED_ONLY_ONCE,
|
||||||
|
))
|
||||||
|
.db_create_login_otp_adapter(mock_create_login_otp_db_port(IS_NEVER_CALLED))
|
||||||
|
.db_delete_login_otp(mock_delete_login_otp_db_port(IS_CALLED_ONLY_ONCE))
|
||||||
|
.db_get_login_otp(mock_get_login_otp_db_port(IS_CALLED_ONLY_ONCE))
|
||||||
|
.random_number_adapter(mock_generate_random_number(IS_NEVER_CALLED, 0))
|
||||||
|
.phone_login_otp_adapter(mock_account_login_otp_phone_port(IS_NEVER_CALLED))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = EmployeeFinishLoginCommandBuilder::default()
|
||||||
|
.phone_number(PhoneNumber::default())
|
||||||
|
.otp(
|
||||||
|
0, // same as the val used in mock
|
||||||
|
)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
let res = s.finish_login(cmd.clone()).await.unwrap();
|
||||||
|
assert_eq!(*res.emp_id(), UUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_finish_login_wrong_otp() {
|
||||||
|
let s = EmployeeLoginServiceBuilder::default()
|
||||||
|
.db_phone_exists_adapter(mock_phone_exists_db_port(IS_NEVER_CALLED, true))
|
||||||
|
.db_get_emp_id_from_phone_number_adapter(mock_get_emp_id_from_phone_number_db_port(
|
||||||
|
IS_NEVER_CALLED,
|
||||||
|
))
|
||||||
|
.db_create_login_otp_adapter(mock_create_login_otp_db_port(IS_NEVER_CALLED))
|
||||||
|
.db_delete_login_otp(mock_delete_login_otp_db_port(IS_NEVER_CALLED))
|
||||||
|
.db_get_login_otp(mock_get_login_otp_db_port(IS_CALLED_ONLY_ONCE))
|
||||||
|
.random_number_adapter(mock_generate_random_number(IS_NEVER_CALLED, 0))
|
||||||
|
.phone_login_otp_adapter(mock_account_login_otp_phone_port(IS_NEVER_CALLED))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = EmployeeFinishLoginCommandBuilder::default()
|
||||||
|
.phone_number(PhoneNumber::default())
|
||||||
|
.otp(9999)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
let res = s.finish_login(cmd.clone()).await;
|
||||||
|
assert_eq!(res.err(), Some(IdentityError::LoginFailed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_finish_login_otp_doesnt_exist() {
|
||||||
|
let s = EmployeeLoginServiceBuilder::default()
|
||||||
|
.db_phone_exists_adapter(mock_phone_exists_db_port(IS_NEVER_CALLED, true))
|
||||||
|
.db_get_emp_id_from_phone_number_adapter(mock_get_emp_id_from_phone_number_db_port(
|
||||||
|
IS_NEVER_CALLED,
|
||||||
|
))
|
||||||
|
.db_create_login_otp_adapter(mock_create_login_otp_db_port(IS_NEVER_CALLED))
|
||||||
|
.db_delete_login_otp(mock_delete_login_otp_db_port(IS_NEVER_CALLED))
|
||||||
|
.db_get_login_otp(mock_get_login_otp_db_port_returns_none(IS_CALLED_ONLY_ONCE))
|
||||||
|
.random_number_adapter(mock_generate_random_number(IS_NEVER_CALLED, 0))
|
||||||
|
.phone_login_otp_adapter(mock_account_login_otp_phone_port(IS_NEVER_CALLED))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = EmployeeFinishLoginCommandBuilder::default()
|
||||||
|
.phone_number(PhoneNumber::default())
|
||||||
|
.otp(0)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
let res = s.finish_login(cmd.clone()).await;
|
||||||
|
assert_eq!(res.err(), Some(IdentityError::LoginOTPNotFound));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
221
src/identity/application/services/employee_register_service.rs
Normal file
221
src/identity/application/services/employee_register_service.rs
Normal file
|
@ -0,0 +1,221 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
use super::*;
|
||||||
|
use crate::identity::application::port::output::{
|
||||||
|
db::{create_verification_otp::*, emp_id_exists::*, phone_exists::*},
|
||||||
|
phone::account_validation_otp::*,
|
||||||
|
};
|
||||||
|
use crate::identity::domain::{
|
||||||
|
employee_aggregate::*, employee_register_command::*, employee_registered_event::*,
|
||||||
|
};
|
||||||
|
use crate::utils::random_number::*;
|
||||||
|
|
||||||
|
pub const OTP_LEN: u32 = 6;
|
||||||
|
|
||||||
|
#[derive(Builder)]
|
||||||
|
pub struct EmployeeRegisterUserService {
|
||||||
|
db_phone_exists_adapter: PhoneNumberExistsOutDBPortObj,
|
||||||
|
db_emp_id_exists_adapter: EmpIDExistsOutDBPortObj,
|
||||||
|
db_create_verification_otp_adapter: CreateVerificationOTPOutDBPortObj,
|
||||||
|
phone_account_validation_otp_adapter: AccountValidationOTPOutPhonePortObj,
|
||||||
|
random_number_adapter: GenerateRandomNumberInterfaceObj,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type EmployeeRegisterServiceObj = std::sync::Arc<dyn EmployeeRegisterUserUseCase>;
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait EmployeeRegisterUserUseCase: Send + Sync {
|
||||||
|
async fn register_employee(
|
||||||
|
&self,
|
||||||
|
cmd: EmployeeRegisterCommand,
|
||||||
|
) -> IdentityResult<EmployeeRegisteredEvent>;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl EmployeeRegisterUserUseCase for EmployeeRegisterUserService {
|
||||||
|
async fn register_employee(
|
||||||
|
&self,
|
||||||
|
cmd: EmployeeRegisterCommand,
|
||||||
|
) -> IdentityResult<EmployeeRegisteredEvent> {
|
||||||
|
if self
|
||||||
|
.db_phone_exists_adapter
|
||||||
|
.phone_exists(cmd.phone_number())
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
{
|
||||||
|
return Err(IdentityError::DuplicatePhoneNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
if self
|
||||||
|
.db_emp_id_exists_adapter
|
||||||
|
.emp_id_exists(cmd.emp_id())
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
{
|
||||||
|
return Err(IdentityError::DuplicateEmployeeID);
|
||||||
|
}
|
||||||
|
|
||||||
|
let otp = self.random_number_adapter.get_random(OTP_LEN);
|
||||||
|
|
||||||
|
self.db_create_verification_otp_adapter
|
||||||
|
.create_verification_otp(
|
||||||
|
CreateOTPMsgBuilder::default()
|
||||||
|
.otp(otp.clone())
|
||||||
|
.emp_id(*cmd.emp_id())
|
||||||
|
.build()
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
self.phone_account_validation_otp_adapter
|
||||||
|
.account_validation_otp(cmd.phone_number(), otp)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let e = EmployeeBuilder::default()
|
||||||
|
.first_name(cmd.first_name().clone())
|
||||||
|
.last_name(cmd.last_name().clone())
|
||||||
|
.emp_id(*cmd.emp_id())
|
||||||
|
.phone_number(cmd.phone_number().clone())
|
||||||
|
.phone_verified(false)
|
||||||
|
.deleted(false)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
Ok(EmployeeRegisteredEventBuilder::default()
|
||||||
|
.employee(e)
|
||||||
|
.build()
|
||||||
|
.unwrap())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use crate::tests::bdd::*;
|
||||||
|
use crate::utils::random_number::tests::*;
|
||||||
|
use crate::utils::uuid::tests::*;
|
||||||
|
|
||||||
|
impl EmployeeRegisterUserService {
|
||||||
|
pub fn mock(
|
||||||
|
times: Option<usize>,
|
||||||
|
cmd: EmployeeRegisterCommand,
|
||||||
|
) -> EmployeeRegisterServiceObj {
|
||||||
|
let res = EmployeeRegisteredEventBuilder::default()
|
||||||
|
.employee(
|
||||||
|
EmployeeBuilder::default()
|
||||||
|
.first_name(cmd.first_name().clone())
|
||||||
|
.last_name(cmd.last_name().clone())
|
||||||
|
.emp_id(*cmd.emp_id())
|
||||||
|
.phone_number(cmd.phone_number().clone())
|
||||||
|
.phone_verified(false)
|
||||||
|
.deleted(false)
|
||||||
|
.build()
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let mut m = MockEmployeeRegisterUserUseCase::default();
|
||||||
|
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_register_employee()
|
||||||
|
.times(times)
|
||||||
|
.returning(move |_| Ok(res.clone()));
|
||||||
|
} else {
|
||||||
|
m.expect_register_employee()
|
||||||
|
.returning(move |_| Ok(res.clone()));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sync::Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service() {
|
||||||
|
let username = "realaravinth";
|
||||||
|
let phone_number = PhoneNumber::default();
|
||||||
|
|
||||||
|
let cmd = EmployeeRegisterCommandBuilder::default()
|
||||||
|
.first_name(username.into())
|
||||||
|
.last_name(username.into())
|
||||||
|
.phone_number(phone_number)
|
||||||
|
.emp_id(UUID)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = EmployeeRegisterUserServiceBuilder::default()
|
||||||
|
.db_emp_id_exists_adapter(mock_emp_id_exists_db_port(
|
||||||
|
IS_CALLED_ONLY_ONCE,
|
||||||
|
RETURNS_FALSE,
|
||||||
|
))
|
||||||
|
.db_create_verification_otp_adapter(mock_create_verification_otp_db_port(
|
||||||
|
IS_CALLED_ONLY_ONCE,
|
||||||
|
))
|
||||||
|
.db_phone_exists_adapter(mock_phone_exists_db_port(
|
||||||
|
IS_CALLED_ONLY_ONCE,
|
||||||
|
RETURNS_FALSE,
|
||||||
|
))
|
||||||
|
.random_number_adapter(mock_generate_random_number(
|
||||||
|
IS_CALLED_ONLY_ONCE,
|
||||||
|
RETURNS_RANDOM_NUMBER.into(),
|
||||||
|
))
|
||||||
|
.phone_account_validation_otp_adapter(mock_account_validation_otp_phone_port(
|
||||||
|
IS_CALLED_ONLY_ONCE,
|
||||||
|
))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let res = s.register_employee(cmd.clone()).await.unwrap();
|
||||||
|
let emp = res.employee();
|
||||||
|
assert_eq!(emp.first_name(), cmd.first_name());
|
||||||
|
assert_eq!(emp.last_name(), cmd.last_name());
|
||||||
|
assert_eq!(emp.emp_id(), &UUID);
|
||||||
|
assert_eq!(emp.phone_number(), cmd.phone_number());
|
||||||
|
assert!(!emp.deleted());
|
||||||
|
assert!(!emp.phone_verified());
|
||||||
|
}
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_phone_exists() {
|
||||||
|
let username = "realaravinth";
|
||||||
|
let phone_number = PhoneNumber::default();
|
||||||
|
|
||||||
|
let cmd = EmployeeRegisterCommandBuilder::default()
|
||||||
|
.first_name(username.into())
|
||||||
|
.last_name(username.into())
|
||||||
|
.phone_number(phone_number)
|
||||||
|
.emp_id(UUID)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let s = EmployeeRegisterUserServiceBuilder::default()
|
||||||
|
.db_emp_id_exists_adapter(mock_emp_id_exists_db_port(IGNORE_CALL_COUNT, RETURNS_FALSE))
|
||||||
|
.db_create_verification_otp_adapter(mock_create_verification_otp_db_port(
|
||||||
|
IS_NEVER_CALLED,
|
||||||
|
))
|
||||||
|
.db_phone_exists_adapter(mock_phone_exists_db_port(IS_CALLED_ONLY_ONCE, RETURNS_TRUE))
|
||||||
|
.random_number_adapter(mock_generate_random_number(
|
||||||
|
IS_NEVER_CALLED,
|
||||||
|
RETURNS_RANDOM_NUMBER.into(),
|
||||||
|
))
|
||||||
|
.phone_account_validation_otp_adapter(mock_account_validation_otp_phone_port(
|
||||||
|
IS_NEVER_CALLED,
|
||||||
|
))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
s.register_employee(cmd.clone()).await.err(),
|
||||||
|
Some(IdentityError::DuplicatePhoneNumber)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,149 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use derive_builder::Builder;
|
||||||
|
|
||||||
|
use crate::identity::application::port::output::{
|
||||||
|
db::{
|
||||||
|
create_login_otp::*, delete_login_otp::*, emp_id_exists::*,
|
||||||
|
get_emp_id_from_phone_number::*, get_login_otp::*, phone_exists::*,
|
||||||
|
},
|
||||||
|
phone::account_login_otp::*,
|
||||||
|
};
|
||||||
|
use crate::identity::domain::{
|
||||||
|
employee_aggregate::*, resend_login_otp_command::*, resend_login_otp_event::*,
|
||||||
|
};
|
||||||
|
use crate::utils::random_number::*;
|
||||||
|
|
||||||
|
use super::employee_register_service::OTP_LEN;
|
||||||
|
use super::errors::*;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait EmployeeResendLoginOTPUseCase: Send + Sync {
|
||||||
|
async fn resend_otp(&self, cmd: ResendLoginOTPCommand) -> IdentityResult<ResentLoginOTPEvent>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type EmployeeResendLoginOTPServiceObj = std::sync::Arc<dyn EmployeeResendLoginOTPUseCase>;
|
||||||
|
|
||||||
|
#[derive(Clone, Builder)]
|
||||||
|
pub struct EmployeeResendLoginOTPService {
|
||||||
|
db_phone_exists_adapter: PhoneNumberExistsOutDBPortObj,
|
||||||
|
db_get_emp_id_from_phone_number_adapter: GetEmpIDFromPhoneNumberOutDBPortObj,
|
||||||
|
db_get_login_otp: GetLoginOTPOutDBPortObj,
|
||||||
|
phone_login_otp_adapter: AccountLoginOTPOutPhonePortObj,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl EmployeeResendLoginOTPUseCase for EmployeeResendLoginOTPService {
|
||||||
|
async fn resend_otp(&self, cmd: ResendLoginOTPCommand) -> IdentityResult<ResentLoginOTPEvent> {
|
||||||
|
if !self
|
||||||
|
.db_phone_exists_adapter
|
||||||
|
.phone_exists(cmd.phone_number())
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
return Err(IdentityError::PhoneNumberNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
let otp = match self
|
||||||
|
.db_get_login_otp
|
||||||
|
.get_login_otp(cmd.phone_number())
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
Some(otp) => otp,
|
||||||
|
None => {
|
||||||
|
return Err(IdentityError::LoginOTPNotFound);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
self.phone_login_otp_adapter
|
||||||
|
.account_login_otp(cmd.phone_number(), otp)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let emp_id = self
|
||||||
|
.db_get_emp_id_from_phone_number_adapter
|
||||||
|
.get_emp_id_from_phone_number(cmd.phone_number())
|
||||||
|
.await?;
|
||||||
|
Ok(ResentLoginOTPEventBuilder::default()
|
||||||
|
.emp_id(emp_id)
|
||||||
|
.build()
|
||||||
|
.unwrap())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::{
|
||||||
|
tests::bdd::*,
|
||||||
|
utils::{random_number::tests::mock_generate_random_number, uuid::tests::*},
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_init_login() {
|
||||||
|
let s = EmployeeResendLoginOTPServiceBuilder::default()
|
||||||
|
.db_phone_exists_adapter(mock_phone_exists_db_port(IS_CALLED_ONLY_ONCE, true))
|
||||||
|
.db_get_emp_id_from_phone_number_adapter(mock_get_emp_id_from_phone_number_db_port(
|
||||||
|
IS_CALLED_ONLY_ONCE,
|
||||||
|
))
|
||||||
|
.db_get_login_otp(mock_get_login_otp_db_port(IS_CALLED_ONLY_ONCE))
|
||||||
|
.phone_login_otp_adapter(mock_account_login_otp_phone_port(IS_CALLED_ONLY_ONCE))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = ResendLoginOTPCommandBuilder::default()
|
||||||
|
.phone_number(PhoneNumber::default())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
let res = s.resend_otp(cmd.clone()).await.unwrap();
|
||||||
|
assert_eq!(res.emp_id(), &UUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_phone_doesnt_exist() {
|
||||||
|
let s = EmployeeResendLoginOTPServiceBuilder::default()
|
||||||
|
.db_phone_exists_adapter(mock_phone_exists_db_port(IS_CALLED_ONLY_ONCE, false))
|
||||||
|
.db_get_emp_id_from_phone_number_adapter(mock_get_emp_id_from_phone_number_db_port(
|
||||||
|
IS_NEVER_CALLED,
|
||||||
|
))
|
||||||
|
.db_get_login_otp(mock_get_login_otp_db_port_returns_none(IS_NEVER_CALLED))
|
||||||
|
.phone_login_otp_adapter(mock_account_login_otp_phone_port(IS_NEVER_CALLED))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = ResendLoginOTPCommandBuilder::default()
|
||||||
|
.phone_number(PhoneNumber::default())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let res = s.resend_otp(cmd.clone()).await;
|
||||||
|
assert_eq!(res.err(), Some(IdentityError::PhoneNumberNotFound))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_otp_doesnt_exist() {
|
||||||
|
let s = EmployeeResendLoginOTPServiceBuilder::default()
|
||||||
|
.db_phone_exists_adapter(mock_phone_exists_db_port(IS_CALLED_ONLY_ONCE, true))
|
||||||
|
.db_get_emp_id_from_phone_number_adapter(mock_get_emp_id_from_phone_number_db_port(
|
||||||
|
IS_NEVER_CALLED,
|
||||||
|
))
|
||||||
|
.db_get_login_otp(mock_get_login_otp_db_port_returns_none(IS_CALLED_ONLY_ONCE))
|
||||||
|
.phone_login_otp_adapter(mock_account_login_otp_phone_port(IS_NEVER_CALLED))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = ResendLoginOTPCommandBuilder::default()
|
||||||
|
.phone_number(PhoneNumber::default())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let res = s.resend_otp(cmd.clone()).await;
|
||||||
|
assert_eq!(res.err(), Some(IdentityError::LoginOTPNotFound))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,158 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use derive_builder::Builder;
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
use crate::identity::domain::resend_verification_otp_command::*;
|
||||||
|
use crate::identity::{
|
||||||
|
application::port::output::{
|
||||||
|
db::{get_emp_id_from_phone_number::*, get_verification_otp::*, phone_exists::*},
|
||||||
|
phone::account_validation_otp::*,
|
||||||
|
},
|
||||||
|
domain::verification_otp_resent_event::*,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait EmployeeResendVerificationOTPUseCase: Send + Sync {
|
||||||
|
async fn resend_otp(
|
||||||
|
&self,
|
||||||
|
cmd: ResendVerificationOTPCommand,
|
||||||
|
) -> IdentityResult<VerificationOTPResentEvent>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type EmployeeResendVerificationOTPServiceObj =
|
||||||
|
std::sync::Arc<dyn EmployeeResendVerificationOTPUseCase>;
|
||||||
|
|
||||||
|
#[derive(Clone, Builder)]
|
||||||
|
pub struct EmployeeResendVerificationOTPService {
|
||||||
|
db_phone_exists_adapter: PhoneNumberExistsOutDBPortObj,
|
||||||
|
db_get_emp_id_from_phone_number_adapter: GetEmpIDFromPhoneNumberOutDBPortObj,
|
||||||
|
db_get_verification_otp: GetVerificationOTPOutDBPortObj,
|
||||||
|
phone_account_validation_otp_adapter: AccountValidationOTPOutPhonePortObj,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl EmployeeResendVerificationOTPUseCase for EmployeeResendVerificationOTPService {
|
||||||
|
async fn resend_otp(
|
||||||
|
&self,
|
||||||
|
cmd: ResendVerificationOTPCommand,
|
||||||
|
) -> IdentityResult<VerificationOTPResentEvent> {
|
||||||
|
if !self
|
||||||
|
.db_phone_exists_adapter
|
||||||
|
.phone_exists(cmd.phone_number())
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
return Err(IdentityError::PhoneNumberNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
let otp = match self
|
||||||
|
.db_get_verification_otp
|
||||||
|
.get_verification_otp(cmd.phone_number())
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
Some(otp) => otp,
|
||||||
|
None => {
|
||||||
|
return Err(IdentityError::VerificationOTPNotFound);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
self.phone_account_validation_otp_adapter
|
||||||
|
.account_validation_otp(cmd.phone_number(), otp)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let emp_id = self
|
||||||
|
.db_get_emp_id_from_phone_number_adapter
|
||||||
|
.get_emp_id_from_phone_number(cmd.phone_number())
|
||||||
|
.await?;
|
||||||
|
Ok(VerificationOTPResentEventBuilder::default()
|
||||||
|
.emp_id(emp_id)
|
||||||
|
.build()
|
||||||
|
.unwrap())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::{identity::domain::employee_aggregate::*, tests::bdd::*, utils::uuid::tests::*};
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_init_login() {
|
||||||
|
let s = EmployeeResendVerificationOTPServiceBuilder::default()
|
||||||
|
.db_phone_exists_adapter(mock_phone_exists_db_port(IS_CALLED_ONLY_ONCE, true))
|
||||||
|
.db_get_emp_id_from_phone_number_adapter(mock_get_emp_id_from_phone_number_db_port(
|
||||||
|
IS_CALLED_ONLY_ONCE,
|
||||||
|
))
|
||||||
|
.db_get_verification_otp(mock_get_verification_otp_db_port(IS_CALLED_ONLY_ONCE))
|
||||||
|
.phone_account_validation_otp_adapter(mock_account_validation_otp_phone_port(
|
||||||
|
IS_CALLED_ONLY_ONCE,
|
||||||
|
))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = ResendVerificationOTPCommandBuilder::default()
|
||||||
|
.phone_number(PhoneNumber::default())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
let res = s.resend_otp(cmd.clone()).await.unwrap();
|
||||||
|
assert_eq!(res.emp_id(), &UUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_phone_doesnt_exist() {
|
||||||
|
let s = EmployeeResendVerificationOTPServiceBuilder::default()
|
||||||
|
.db_phone_exists_adapter(mock_phone_exists_db_port(IS_CALLED_ONLY_ONCE, false))
|
||||||
|
.db_get_emp_id_from_phone_number_adapter(mock_get_emp_id_from_phone_number_db_port(
|
||||||
|
IS_NEVER_CALLED,
|
||||||
|
))
|
||||||
|
.db_get_verification_otp(mock_get_verification_otp_db_port_returns_none(
|
||||||
|
IS_NEVER_CALLED,
|
||||||
|
))
|
||||||
|
.phone_account_validation_otp_adapter(mock_account_validation_otp_phone_port(
|
||||||
|
IS_NEVER_CALLED,
|
||||||
|
))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = ResendVerificationOTPCommandBuilder::default()
|
||||||
|
.phone_number(PhoneNumber::default())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let res = s.resend_otp(cmd.clone()).await;
|
||||||
|
assert_eq!(res.err(), Some(IdentityError::PhoneNumberNotFound))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_otp_doesnt_exist() {
|
||||||
|
let s = EmployeeResendVerificationOTPServiceBuilder::default()
|
||||||
|
.db_phone_exists_adapter(mock_phone_exists_db_port(IS_CALLED_ONLY_ONCE, true))
|
||||||
|
.db_get_emp_id_from_phone_number_adapter(mock_get_emp_id_from_phone_number_db_port(
|
||||||
|
IS_NEVER_CALLED,
|
||||||
|
))
|
||||||
|
.db_get_verification_otp(mock_get_verification_otp_db_port_returns_none(
|
||||||
|
IS_CALLED_ONLY_ONCE,
|
||||||
|
))
|
||||||
|
.phone_account_validation_otp_adapter(mock_account_validation_otp_phone_port(
|
||||||
|
IS_NEVER_CALLED,
|
||||||
|
))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = ResendVerificationOTPCommandBuilder::default()
|
||||||
|
.phone_number(PhoneNumber::default())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let res = s.resend_otp(cmd.clone()).await;
|
||||||
|
assert_eq!(res.err(), Some(IdentityError::VerificationOTPNotFound))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,142 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use derive_builder::Builder;
|
||||||
|
|
||||||
|
use crate::identity::application::port::output::db::{
|
||||||
|
delete_verification_otp::*, get_emp_id_from_phone_number::*, get_verification_otp::*,
|
||||||
|
};
|
||||||
|
use crate::identity::domain::{phone_number_verified_event::*, verify_phone_number_command::*};
|
||||||
|
|
||||||
|
use super::errors::*;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
pub trait EmployeeVerifyPhoneNumberUseCase: Send + Sync {
|
||||||
|
async fn verify_phone_number(
|
||||||
|
&self,
|
||||||
|
cmd: VerifyPhoneNumberCommand,
|
||||||
|
) -> IdentityResult<PhoneNumberVerifiedEvent>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type EmployeeVerifyPhoneNumberServiceObj = std::sync::Arc<dyn EmployeeVerifyPhoneNumberUseCase>;
|
||||||
|
|
||||||
|
#[derive(Clone, Builder)]
|
||||||
|
pub struct EmployeeVerifyPhoneNumberService {
|
||||||
|
db_get_emp_id_from_phone_number_adapter: GetEmpIDFromPhoneNumberOutDBPortObj,
|
||||||
|
db_delete_verification_otp: DeleteVerificationOTPOutDBPortObj,
|
||||||
|
db_get_verification_otp: GetVerificationOTPOutDBPortObj,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl EmployeeVerifyPhoneNumberUseCase for EmployeeVerifyPhoneNumberService {
|
||||||
|
async fn verify_phone_number(
|
||||||
|
&self,
|
||||||
|
cmd: VerifyPhoneNumberCommand,
|
||||||
|
) -> IdentityResult<PhoneNumberVerifiedEvent> {
|
||||||
|
match self
|
||||||
|
.db_get_verification_otp
|
||||||
|
.get_verification_otp(cmd.phone_number())
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
Some(otp) => {
|
||||||
|
if otp == *cmd.otp() {
|
||||||
|
self.db_delete_verification_otp
|
||||||
|
.delete_verification_otp(*cmd.otp(), cmd.phone_number())
|
||||||
|
.await?;
|
||||||
|
} else {
|
||||||
|
return Err(IdentityError::PhoneNumberVerificationFailed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => return Err(IdentityError::VerificationOTPNotFound),
|
||||||
|
}
|
||||||
|
let emp_id = self
|
||||||
|
.db_get_emp_id_from_phone_number_adapter
|
||||||
|
.get_emp_id_from_phone_number(cmd.phone_number())
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(PhoneNumberVerifiedEventBuilder::default()
|
||||||
|
.emp_id(emp_id)
|
||||||
|
.build()
|
||||||
|
.unwrap())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::{identity::domain::employee_aggregate::*, tests::bdd::*, utils::uuid::tests::*};
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_verify_phone_number() {
|
||||||
|
let s = EmployeeVerifyPhoneNumberServiceBuilder::default()
|
||||||
|
.db_get_emp_id_from_phone_number_adapter(mock_get_emp_id_from_phone_number_db_port(
|
||||||
|
IS_CALLED_ONLY_ONCE,
|
||||||
|
))
|
||||||
|
.db_delete_verification_otp(mock_delete_verification_otp_db_port(IS_CALLED_ONLY_ONCE))
|
||||||
|
.db_get_verification_otp(mock_get_verification_otp_db_port(IS_CALLED_ONLY_ONCE))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = VerifyPhoneNumberCommandBuilder::default()
|
||||||
|
.phone_number(PhoneNumber::default())
|
||||||
|
.otp(
|
||||||
|
0, // same as the val used in mock
|
||||||
|
)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
let res = s.verify_phone_number(cmd.clone()).await.unwrap();
|
||||||
|
assert_eq!(*res.emp_id(), UUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_verify_phone_number_wrong_otp() {
|
||||||
|
let s = EmployeeVerifyPhoneNumberServiceBuilder::default()
|
||||||
|
.db_get_emp_id_from_phone_number_adapter(mock_get_emp_id_from_phone_number_db_port(
|
||||||
|
IS_NEVER_CALLED,
|
||||||
|
))
|
||||||
|
.db_delete_verification_otp(mock_delete_verification_otp_db_port(IS_NEVER_CALLED))
|
||||||
|
.db_get_verification_otp(mock_get_verification_otp_db_port(IS_CALLED_ONLY_ONCE))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = VerifyPhoneNumberCommandBuilder::default()
|
||||||
|
.phone_number(PhoneNumber::default())
|
||||||
|
.otp(9999)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
let res = s.verify_phone_number(cmd.clone()).await;
|
||||||
|
assert_eq!(
|
||||||
|
res.err(),
|
||||||
|
Some(IdentityError::PhoneNumberVerificationFailed)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn test_service_verify_phone_number_otp_doesnt_exist() {
|
||||||
|
let s = EmployeeVerifyPhoneNumberServiceBuilder::default()
|
||||||
|
.db_get_emp_id_from_phone_number_adapter(mock_get_emp_id_from_phone_number_db_port(
|
||||||
|
IS_NEVER_CALLED,
|
||||||
|
))
|
||||||
|
.db_delete_verification_otp(mock_delete_verification_otp_db_port(IS_NEVER_CALLED))
|
||||||
|
.db_get_verification_otp(mock_get_verification_otp_db_port_returns_none(
|
||||||
|
IS_CALLED_ONLY_ONCE,
|
||||||
|
))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cmd = VerifyPhoneNumberCommandBuilder::default()
|
||||||
|
.phone_number(PhoneNumber::default())
|
||||||
|
.otp(0)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
let res = s.verify_phone_number(cmd.clone()).await;
|
||||||
|
assert_eq!(res.err(), Some(IdentityError::VerificationOTPNotFound));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,13 +6,29 @@ use argon2_creds::CredsError;
|
||||||
use derive_more::{Display, Error};
|
use derive_more::{Display, Error};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::identity::application::port::output::{
|
||||||
|
db::errors::OutDBPortError, phone::errors::OutPhonePortError,
|
||||||
|
};
|
||||||
|
|
||||||
pub type IdentityResult<V> = Result<V, IdentityError>;
|
pub type IdentityResult<V> = Result<V, IdentityError>;
|
||||||
|
|
||||||
#[derive(Debug, Error, Display, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug, Error, Display, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub enum IdentityError {
|
pub enum IdentityError {
|
||||||
DuplicateUsername,
|
DuplicateUsername,
|
||||||
VerificationOTPSecretNotFound,
|
VerificationOTPNotFound,
|
||||||
|
VerificationSecretNotFound,
|
||||||
|
PhoneNumberVerificationFailed,
|
||||||
|
LoginOTPNotFound,
|
||||||
|
LoginFailed,
|
||||||
DuplicateEmail,
|
DuplicateEmail,
|
||||||
|
DuplicateEmployeeID,
|
||||||
|
DuplicatePhoneNumber,
|
||||||
|
DuplicateVerificationOTP,
|
||||||
|
InternalError,
|
||||||
|
PhoneNumberNotFound,
|
||||||
|
EmployeeNotFound,
|
||||||
|
InviteNotFound,
|
||||||
|
StoreNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type IdentityCommandResult<V> = Result<V, IdentityCommandError>;
|
pub type IdentityCommandResult<V> = Result<V, IdentityCommandError>;
|
||||||
|
@ -37,3 +53,21 @@ impl From<CredsError> for IdentityCommandError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<OutPhonePortError> for IdentityError {
|
||||||
|
fn from(v: OutPhonePortError) -> Self {
|
||||||
|
match v {
|
||||||
|
OutPhonePortError::InternalError => Self::InternalError,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl From<OutDBPortError> for IdentityError {
|
||||||
|
fn from(v: OutDBPortError) -> Self {
|
||||||
|
match v {
|
||||||
|
OutDBPortError::InternalError => Self::InternalError,
|
||||||
|
OutDBPortError::DuplicateVerificationOTPSecret => Self::DuplicateVerificationOTP,
|
||||||
|
OutDBPortError::VerificationSecretNotFound => Self::VerificationSecretNotFound,
|
||||||
|
OutDBPortError::VerificationOTPNotFound => Self::VerificationOTPNotFound,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -11,8 +11,15 @@ use super::set_user_admin::events::*;
|
||||||
use super::update_email::events::*;
|
use super::update_email::events::*;
|
||||||
use super::update_password::events::*;
|
use super::update_password::events::*;
|
||||||
|
|
||||||
|
use crate::identity::domain::{
|
||||||
|
employee_logged_in_event::*, employee_registered_event::*, invite_accepted_event::*,
|
||||||
|
login_otp_sent_event::*, organization_exited_event::*, phone_number_changed_event::*,
|
||||||
|
phone_number_verified_event::*, resend_login_otp_event::*, verification_otp_resent_event::*,
|
||||||
|
verification_otp_sent_event::*,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd)]
|
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd)]
|
||||||
pub enum UserEvent {
|
pub enum IdentityEvent {
|
||||||
UserRegistered(UserRegisteredEvent),
|
UserRegistered(UserRegisteredEvent),
|
||||||
UserDeleted,
|
UserDeleted,
|
||||||
Loggedin(LoginEvent),
|
Loggedin(LoginEvent),
|
||||||
|
@ -21,25 +28,47 @@ pub enum UserEvent {
|
||||||
UserVerified,
|
UserVerified,
|
||||||
VerificationEmailResent,
|
VerificationEmailResent,
|
||||||
UserPromotedToAdmin(UserPromotedToAdminEvent),
|
UserPromotedToAdmin(UserPromotedToAdminEvent),
|
||||||
|
|
||||||
|
// employee
|
||||||
|
EmployeeRegistered(EmployeeRegisteredEvent),
|
||||||
|
EmployeeLoggedIn(EmployeeLoggedInEvent),
|
||||||
|
EmployeeInitLoggedIn(EmployeeInitLoggedInEvent),
|
||||||
|
ResentLoginOTP(ResentLoginOTPEvent),
|
||||||
|
PhoneNumberVerified(PhoneNumberVerifiedEvent),
|
||||||
|
VerificationOTPResent(VerificationOTPResentEvent),
|
||||||
|
PhoneNumberChanged(PhoneNumberChangedEvent),
|
||||||
|
InviteAccepted(InviteAcceptedEvent),
|
||||||
|
OrganizationExited(OrganizationExitedEvent),
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: define password type that takes string and converts to hash
|
//TODO: define password type that takes string and converts to hash
|
||||||
|
|
||||||
impl DomainEvent for UserEvent {
|
impl DomainEvent for IdentityEvent {
|
||||||
fn event_version(&self) -> String {
|
fn event_version(&self) -> String {
|
||||||
"1.0".to_string()
|
"1.0".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn event_type(&self) -> String {
|
fn event_type(&self) -> String {
|
||||||
let e: &str = match self {
|
let e: &str = match self {
|
||||||
UserEvent::UserRegistered { .. } => "UserRegisteredAccount",
|
IdentityEvent::UserRegistered { .. } => "IdentityUserRegisteredAccount",
|
||||||
UserEvent::UserDeleted => "UserDeletedAccount",
|
IdentityEvent::UserDeleted => "IdentityUserDeletedAccount",
|
||||||
UserEvent::Loggedin { .. } => "UserLoggedIn",
|
IdentityEvent::Loggedin { .. } => "IdentityUserLoggedIn",
|
||||||
UserEvent::PasswordUpdated { .. } => "UserUpdatedAccountPassword",
|
IdentityEvent::Loggedin { .. } => "IdentityUserLoggedIn",
|
||||||
UserEvent::EmailUpdated { .. } => "UserUpdatedAccountEmail",
|
IdentityEvent::PasswordUpdated { .. } => "IdentityUserUpdatedAccountPassword",
|
||||||
UserEvent::UserVerified => "UserIsVerified",
|
IdentityEvent::EmailUpdated { .. } => "IdentityUserUpdatedAccountEmail",
|
||||||
UserEvent::UserPromotedToAdmin { .. } => "UserPromotedToAdmin",
|
IdentityEvent::UserVerified => "IdentityUserIsVerified",
|
||||||
UserEvent::VerificationEmailResent => "VerficationEmailResent",
|
IdentityEvent::UserPromotedToAdmin { .. } => "IdentityUserPromotedToAdmin",
|
||||||
|
IdentityEvent::VerificationEmailResent => "IdentityVerficationEmailResent",
|
||||||
|
// employee
|
||||||
|
IdentityEvent::EmployeeRegistered { .. } => "EmployeeRegistered",
|
||||||
|
IdentityEvent::EmployeeLoggedIn { .. } => "EmployeeLoggedIn",
|
||||||
|
IdentityEvent::EmployeeInitLoggedIn { .. } => "EmployeeInitLoggedIn",
|
||||||
|
IdentityEvent::ResentLoginOTP { .. } => "EmployeeResentLoginOTP",
|
||||||
|
IdentityEvent::PhoneNumberVerified { .. } => "EmployeePhoneNumberVerified",
|
||||||
|
IdentityEvent::VerificationOTPResent { .. } => "EmployeeVerificationOTPResent",
|
||||||
|
IdentityEvent::PhoneNumberChanged { .. } => "EmployeePhoneNumberChanged",
|
||||||
|
IdentityEvent::InviteAccepted { .. } => "EmployeeInviteAccepted",
|
||||||
|
IdentityEvent::OrganizationExited { .. } => "EmployeeOrganizationExited",
|
||||||
};
|
};
|
||||||
|
|
||||||
e.to_string()
|
e.to_string()
|
||||||
|
|
|
@ -32,7 +32,7 @@ impl MarkUserVerifiedUseCase for MarkUserVerifiedService {
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
{
|
{
|
||||||
return Err(IdentityError::VerificationOTPSecretNotFound);
|
return Err(IdentityError::VerificationOTPNotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.db_delete_verification_secret_adapter
|
self.db_delete_verification_secret_adapter
|
||||||
|
@ -87,7 +87,7 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
s.mark_user_verified(cmd.clone()).await.err(),
|
s.mark_user_verified(cmd.clone()).await.err(),
|
||||||
Some(IdentityError::VerificationOTPSecretNotFound)
|
Some(IdentityError::VerificationOTPNotFound)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,17 +7,29 @@ use mockall::predicate::*;
|
||||||
use mockall::*;
|
use mockall::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
mod delete_user;
|
pub mod delete_user;
|
||||||
|
pub mod employee_accept_invite_service;
|
||||||
|
pub mod employee_exit_organization_service;
|
||||||
|
pub mod employee_login_service;
|
||||||
|
pub mod employee_register_service;
|
||||||
|
pub mod employee_resend_login_otp_service;
|
||||||
|
pub mod employee_resend_verification_otp_service;
|
||||||
|
pub mod employee_verify_phone_number_service;
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
pub mod events;
|
pub mod events;
|
||||||
mod login;
|
pub mod login;
|
||||||
mod mark_user_verified;
|
pub mod mark_user_verified;
|
||||||
mod register_user;
|
pub mod register_user;
|
||||||
mod resend_verification_email;
|
pub mod resend_verification_email;
|
||||||
mod set_user_admin;
|
pub mod set_user_admin;
|
||||||
mod update_email;
|
pub mod update_email;
|
||||||
mod update_password;
|
pub mod update_password;
|
||||||
|
|
||||||
|
use crate::identity::domain::{
|
||||||
|
accept_invite_command::*, change_phone_number_command::*, employee_login_command::*,
|
||||||
|
employee_register_command::*, exit_organization_command::*, resend_login_otp_command::*,
|
||||||
|
resend_verification_otp_command::*, verify_phone_number_command::*,
|
||||||
|
};
|
||||||
use delete_user::command::*;
|
use delete_user::command::*;
|
||||||
use login::command::*;
|
use login::command::*;
|
||||||
use mark_user_verified::command::*;
|
use mark_user_verified::command::*;
|
||||||
|
@ -28,7 +40,7 @@ use update_email::command::*;
|
||||||
use update_password::command::*;
|
use update_password::command::*;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd)]
|
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd)]
|
||||||
pub enum UserCommand {
|
pub enum IdentityCommand {
|
||||||
RegisterUser(RegisterUserCommand),
|
RegisterUser(RegisterUserCommand),
|
||||||
DeleteUser(DeleteUserCommand),
|
DeleteUser(DeleteUserCommand),
|
||||||
Login(LoginCommand),
|
Login(LoginCommand),
|
||||||
|
@ -37,10 +49,20 @@ pub enum UserCommand {
|
||||||
MarkUserVerified(MarkUserVerifiedCommand),
|
MarkUserVerified(MarkUserVerifiedCommand),
|
||||||
SetAdmin(SetAdminCommand),
|
SetAdmin(SetAdminCommand),
|
||||||
ResendVerificationEmail(ResendVerificationEmailCommand),
|
ResendVerificationEmail(ResendVerificationEmailCommand),
|
||||||
|
// employee
|
||||||
|
EmployeeRegister(EmployeeRegisterCommand),
|
||||||
|
EmployeeInitLogin(EmployeeInitLoginCommand),
|
||||||
|
EmployeeFinishLogin(EmployeeFinishLoginCommand),
|
||||||
|
EmployeeResendLoginOTP(ResendLoginOTPCommand),
|
||||||
|
EmployeeVerifyPhoneNumber(VerifyPhoneNumberCommand),
|
||||||
|
EmployeeResendVerificationOTP(ResendVerificationOTPCommand),
|
||||||
|
EmployeeChangePhoneNumber(ChangePhoneNumberCommand),
|
||||||
|
EmployeeAcceptInvite(AcceptInviteCommand),
|
||||||
|
EmployeeExitOrganization(ExitOrganizationCommand),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[automock]
|
#[automock]
|
||||||
pub trait UserServicesInterface: Send + Sync {
|
pub trait IdentityServicesInterface: Send + Sync {
|
||||||
fn delete_user(&self) -> delete_user::DeleteUserServiceObj;
|
fn delete_user(&self) -> delete_user::DeleteUserServiceObj;
|
||||||
fn login(&self) -> login::LoginServiceObj;
|
fn login(&self) -> login::LoginServiceObj;
|
||||||
fn mark_user_verified(&self) -> mark_user_verified::MarkUserVerifiedServiceObj;
|
fn mark_user_verified(&self) -> mark_user_verified::MarkUserVerifiedServiceObj;
|
||||||
|
@ -51,10 +73,29 @@ pub trait UserServicesInterface: Send + Sync {
|
||||||
fn set_user_admin(&self) -> set_user_admin::SetUserAdminServiceObj;
|
fn set_user_admin(&self) -> set_user_admin::SetUserAdminServiceObj;
|
||||||
fn update_email(&self) -> update_email::UpdateEmailServiceObj;
|
fn update_email(&self) -> update_email::UpdateEmailServiceObj;
|
||||||
fn update_password(&self) -> update_password::UpdatePasswordServiceObj;
|
fn update_password(&self) -> update_password::UpdatePasswordServiceObj;
|
||||||
|
|
||||||
|
// employee
|
||||||
|
fn employee_accept_invite_service(
|
||||||
|
&self,
|
||||||
|
) -> employee_accept_invite_service::EmployeeAcceptInviteServiceObj;
|
||||||
|
fn employee_exit_organization_service(
|
||||||
|
&self,
|
||||||
|
) -> employee_exit_organization_service::EmployeeExitOrganizationServiceObj;
|
||||||
|
fn employee_login_service(&self) -> employee_login_service::EmployeeLoginServiceObj;
|
||||||
|
fn employee_register_service(&self) -> employee_register_service::EmployeeRegisterServiceObj;
|
||||||
|
fn employee_resend_login_otp_service(
|
||||||
|
&self,
|
||||||
|
) -> employee_resend_login_otp_service::EmployeeResendLoginOTPServiceObj;
|
||||||
|
fn employee_resend_verification_otp_service(
|
||||||
|
&self,
|
||||||
|
) -> employee_resend_verification_otp_service::EmployeeResendVerificationOTPServiceObj;
|
||||||
|
fn employee_verify_phone_number_service(
|
||||||
|
&self,
|
||||||
|
) -> employee_verify_phone_number_service::EmployeeVerifyPhoneNumberServiceObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Builder)]
|
#[derive(Clone, Builder)]
|
||||||
pub struct UserServices {
|
pub struct IdentityServices {
|
||||||
delete_user: delete_user::DeleteUserServiceObj,
|
delete_user: delete_user::DeleteUserServiceObj,
|
||||||
login: login::LoginServiceObj,
|
login: login::LoginServiceObj,
|
||||||
mark_user_verified: mark_user_verified::MarkUserVerifiedServiceObj,
|
mark_user_verified: mark_user_verified::MarkUserVerifiedServiceObj,
|
||||||
|
@ -63,9 +104,21 @@ pub struct UserServices {
|
||||||
set_user_admin: set_user_admin::SetUserAdminServiceObj,
|
set_user_admin: set_user_admin::SetUserAdminServiceObj,
|
||||||
update_email: update_email::UpdateEmailServiceObj,
|
update_email: update_email::UpdateEmailServiceObj,
|
||||||
update_password: update_password::UpdatePasswordServiceObj,
|
update_password: update_password::UpdatePasswordServiceObj,
|
||||||
|
|
||||||
|
employee_accept_invite_service: employee_accept_invite_service::EmployeeAcceptInviteServiceObj,
|
||||||
|
employee_exit_organization_service:
|
||||||
|
employee_exit_organization_service::EmployeeExitOrganizationServiceObj,
|
||||||
|
employee_login_service: employee_login_service::EmployeeLoginServiceObj,
|
||||||
|
employee_register_service: employee_register_service::EmployeeRegisterServiceObj,
|
||||||
|
employee_resend_login_otp_service:
|
||||||
|
employee_resend_login_otp_service::EmployeeResendLoginOTPServiceObj,
|
||||||
|
employee_resend_verification_otp_service:
|
||||||
|
employee_resend_verification_otp_service::EmployeeResendVerificationOTPServiceObj,
|
||||||
|
employee_verify_phone_number_service:
|
||||||
|
employee_verify_phone_number_service::EmployeeVerifyPhoneNumberServiceObj,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UserServicesInterface for UserServices {
|
impl IdentityServicesInterface for IdentityServices {
|
||||||
fn delete_user(&self) -> delete_user::DeleteUserServiceObj {
|
fn delete_user(&self) -> delete_user::DeleteUserServiceObj {
|
||||||
self.delete_user.clone()
|
self.delete_user.clone()
|
||||||
}
|
}
|
||||||
|
@ -92,4 +145,37 @@ impl UserServicesInterface for UserServices {
|
||||||
fn update_password(&self) -> update_password::UpdatePasswordServiceObj {
|
fn update_password(&self) -> update_password::UpdatePasswordServiceObj {
|
||||||
self.update_password.clone()
|
self.update_password.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// employee
|
||||||
|
fn employee_accept_invite_service(
|
||||||
|
&self,
|
||||||
|
) -> employee_accept_invite_service::EmployeeAcceptInviteServiceObj {
|
||||||
|
self.employee_accept_invite_service.clone()
|
||||||
|
}
|
||||||
|
fn employee_exit_organization_service(
|
||||||
|
&self,
|
||||||
|
) -> employee_exit_organization_service::EmployeeExitOrganizationServiceObj {
|
||||||
|
self.employee_exit_organization_service.clone()
|
||||||
|
}
|
||||||
|
fn employee_login_service(&self) -> employee_login_service::EmployeeLoginServiceObj {
|
||||||
|
self.employee_login_service.clone()
|
||||||
|
}
|
||||||
|
fn employee_register_service(&self) -> employee_register_service::EmployeeRegisterServiceObj {
|
||||||
|
self.employee_register_service.clone()
|
||||||
|
}
|
||||||
|
fn employee_resend_login_otp_service(
|
||||||
|
&self,
|
||||||
|
) -> employee_resend_login_otp_service::EmployeeResendLoginOTPServiceObj {
|
||||||
|
self.employee_resend_login_otp_service.clone()
|
||||||
|
}
|
||||||
|
fn employee_resend_verification_otp_service(
|
||||||
|
&self,
|
||||||
|
) -> employee_resend_verification_otp_service::EmployeeResendVerificationOTPServiceObj {
|
||||||
|
self.employee_resend_verification_otp_service.clone()
|
||||||
|
}
|
||||||
|
fn employee_verify_phone_number_service(
|
||||||
|
&self,
|
||||||
|
) -> employee_verify_phone_number_service::EmployeeVerifyPhoneNumberServiceObj {
|
||||||
|
self.employee_verify_phone_number_service.clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
18
src/identity/domain/accept_invite_command.rs
Normal file
18
src/identity/domain/accept_invite_command.rs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct AcceptInviteCommand {
|
||||||
|
emp_id: Uuid,
|
||||||
|
invite_id: Uuid,
|
||||||
|
}
|
|
@ -10,9 +10,9 @@ use serde::{Deserialize, Serialize};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::identity::application::services::errors::*;
|
use crate::identity::application::services::errors::*;
|
||||||
use crate::identity::application::services::events::UserEvent;
|
use crate::identity::application::services::events::IdentityEvent;
|
||||||
use crate::identity::application::services::UserCommand;
|
use crate::identity::application::services::IdentityCommand;
|
||||||
use crate::identity::application::services::UserServicesInterface;
|
use crate::identity::application::services::IdentityServicesInterface;
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
@ -78,10 +78,10 @@ impl User {
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Aggregate for User {
|
impl Aggregate for User {
|
||||||
type Command = UserCommand;
|
type Command = IdentityCommand;
|
||||||
type Event = UserEvent;
|
type Event = IdentityEvent;
|
||||||
type Error = IdentityError;
|
type Error = IdentityError;
|
||||||
type Services = std::sync::Arc<dyn UserServicesInterface>;
|
type Services = std::sync::Arc<dyn IdentityServicesInterface>;
|
||||||
|
|
||||||
// This identifier should be unique to the system.
|
// This identifier should be unique to the system.
|
||||||
fn aggregate_type() -> String {
|
fn aggregate_type() -> String {
|
||||||
|
@ -96,50 +96,51 @@ impl Aggregate for User {
|
||||||
services: &Self::Services,
|
services: &Self::Services,
|
||||||
) -> Result<Vec<Self::Event>, Self::Error> {
|
) -> Result<Vec<Self::Event>, Self::Error> {
|
||||||
match command {
|
match command {
|
||||||
UserCommand::RegisterUser(cmd) => {
|
IdentityCommand::RegisterUser(cmd) => {
|
||||||
let res = services.register_user().register_user(cmd).await?;
|
let res = services.register_user().register_user(cmd).await?;
|
||||||
Ok(vec![UserEvent::UserRegistered(res)])
|
Ok(vec![IdentityEvent::UserRegistered(res)])
|
||||||
}
|
}
|
||||||
UserCommand::DeleteUser(cmd) => {
|
IdentityCommand::DeleteUser(cmd) => {
|
||||||
services.delete_user().delete_user(cmd).await;
|
services.delete_user().delete_user(cmd).await;
|
||||||
Ok(vec![UserEvent::UserDeleted])
|
Ok(vec![IdentityEvent::UserDeleted])
|
||||||
}
|
}
|
||||||
UserCommand::Login(cmd) => {
|
IdentityCommand::Login(cmd) => {
|
||||||
let res = services.login().login(cmd).await;
|
let res = services.login().login(cmd).await;
|
||||||
Ok(vec![UserEvent::Loggedin(res)])
|
Ok(vec![IdentityEvent::Loggedin(res)])
|
||||||
}
|
}
|
||||||
UserCommand::UpdatePassword(cmd) => {
|
IdentityCommand::UpdatePassword(cmd) => {
|
||||||
let res = services.update_password().update_password(cmd).await;
|
let res = services.update_password().update_password(cmd).await;
|
||||||
Ok(vec![UserEvent::PasswordUpdated(res)])
|
Ok(vec![IdentityEvent::PasswordUpdated(res)])
|
||||||
}
|
}
|
||||||
UserCommand::UpdateEmail(cmd) => {
|
IdentityCommand::UpdateEmail(cmd) => {
|
||||||
let res = services.update_email().update_email(cmd).await?;
|
let res = services.update_email().update_email(cmd).await?;
|
||||||
Ok(vec![UserEvent::EmailUpdated(res)])
|
Ok(vec![IdentityEvent::EmailUpdated(res)])
|
||||||
}
|
}
|
||||||
UserCommand::MarkUserVerified(cmd) => {
|
IdentityCommand::MarkUserVerified(cmd) => {
|
||||||
services
|
services
|
||||||
.mark_user_verified()
|
.mark_user_verified()
|
||||||
.mark_user_verified(cmd)
|
.mark_user_verified(cmd)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(vec![UserEvent::UserVerified])
|
Ok(vec![IdentityEvent::UserVerified])
|
||||||
}
|
}
|
||||||
UserCommand::SetAdmin(cmd) => {
|
IdentityCommand::SetAdmin(cmd) => {
|
||||||
let res = services.set_user_admin().set_user_admin(cmd).await;
|
let res = services.set_user_admin().set_user_admin(cmd).await;
|
||||||
Ok(vec![UserEvent::UserPromotedToAdmin(res)])
|
Ok(vec![IdentityEvent::UserPromotedToAdmin(res)])
|
||||||
}
|
}
|
||||||
UserCommand::ResendVerificationEmail(cmd) => {
|
IdentityCommand::ResendVerificationEmail(cmd) => {
|
||||||
services
|
services
|
||||||
.resend_verification_email()
|
.resend_verification_email()
|
||||||
.resend_verification_email(cmd)
|
.resend_verification_email(cmd)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(vec![UserEvent::VerificationEmailResent])
|
Ok(vec![IdentityEvent::VerificationEmailResent])
|
||||||
}
|
}
|
||||||
|
_ => Ok(Vec::new()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply(&mut self, event: Self::Event) {
|
fn apply(&mut self, event: Self::Event) {
|
||||||
match event {
|
match event {
|
||||||
UserEvent::UserRegistered(e) => {
|
IdentityEvent::UserRegistered(e) => {
|
||||||
self.first_name = e.first_name().into();
|
self.first_name = e.first_name().into();
|
||||||
self.last_name = e.last_name().into();
|
self.last_name = e.last_name().into();
|
||||||
self.user_id = *e.user_id();
|
self.user_id = *e.user_id();
|
||||||
|
@ -150,23 +151,24 @@ impl Aggregate for User {
|
||||||
self.is_verified = *e.is_verified();
|
self.is_verified = *e.is_verified();
|
||||||
self.deleted = false;
|
self.deleted = false;
|
||||||
}
|
}
|
||||||
UserEvent::UserDeleted => {
|
IdentityEvent::UserDeleted => {
|
||||||
self.set_deleted(true);
|
self.set_deleted(true);
|
||||||
}
|
}
|
||||||
UserEvent::Loggedin(_) => (),
|
IdentityEvent::Loggedin(_) => (),
|
||||||
UserEvent::PasswordUpdated(_) => (),
|
IdentityEvent::PasswordUpdated(_) => (),
|
||||||
UserEvent::EmailUpdated(e) => {
|
IdentityEvent::EmailUpdated(e) => {
|
||||||
self.set_email(e.new_email().into());
|
self.set_email(e.new_email().into());
|
||||||
self.set_email_verified(false);
|
self.set_email_verified(false);
|
||||||
}
|
}
|
||||||
UserEvent::UserVerified => {
|
IdentityEvent::UserVerified => {
|
||||||
self.set_is_verified(true);
|
self.set_is_verified(true);
|
||||||
self.set_email_verified(true);
|
self.set_email_verified(true);
|
||||||
}
|
}
|
||||||
UserEvent::UserPromotedToAdmin(_) => {
|
IdentityEvent::UserPromotedToAdmin(_) => {
|
||||||
self.set_is_admin(true);
|
self.set_is_admin(true);
|
||||||
}
|
}
|
||||||
UserEvent::VerificationEmailResent => (),
|
IdentityEvent::VerificationEmailResent => (),
|
||||||
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
17
src/identity/domain/change_phone_number_command.rs
Normal file
17
src/identity/domain/change_phone_number_command.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct ChangePhoneNumberCommand {
|
||||||
|
phone_number: PhoneNumber,
|
||||||
|
}
|
251
src/identity/domain/employee_aggregate.rs
Normal file
251
src/identity/domain/employee_aggregate.rs
Normal file
|
@ -0,0 +1,251 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use async_trait::async_trait;
|
||||||
|
use cqrs_es::Aggregate;
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use events::IdentityEvent;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use crate::identity::application::services::{errors::*, *};
|
||||||
|
|
||||||
|
//use crate::identity::application::services::EmployeeServicesInterface;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct Employee {
|
||||||
|
first_name: String,
|
||||||
|
last_name: String,
|
||||||
|
emp_id: Uuid,
|
||||||
|
phone_number: PhoneNumber,
|
||||||
|
phone_verified: bool,
|
||||||
|
#[builder(default = "None")]
|
||||||
|
store_id: Option<Uuid>,
|
||||||
|
deleted: bool,
|
||||||
|
}
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
#[builder(build_fn(validate = "Self::validate"))]
|
||||||
|
pub struct PhoneNumber {
|
||||||
|
country_code: usize,
|
||||||
|
number: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PhoneNumberBuilder {
|
||||||
|
pub fn validate(&self) -> Result<(), String> {
|
||||||
|
if self.country_code.unwrap() == 91 {
|
||||||
|
if self.number.unwrap().to_string().len() != 10 {
|
||||||
|
return Err("Indian phone number must have 10 digits".into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for PhoneNumber {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
country_code: 91,
|
||||||
|
number: 1234567890,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Employee {
|
||||||
|
fn default() -> Self {
|
||||||
|
Employee {
|
||||||
|
first_name: "".to_string(),
|
||||||
|
last_name: "".to_string(),
|
||||||
|
phone_number: Default::default(),
|
||||||
|
phone_verified: false,
|
||||||
|
deleted: false,
|
||||||
|
emp_id: Uuid::new_v4(),
|
||||||
|
store_id: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl Aggregate for Employee {
|
||||||
|
type Command = IdentityCommand;
|
||||||
|
type Event = IdentityEvent;
|
||||||
|
type Error = IdentityError;
|
||||||
|
type Services = std::sync::Arc<dyn IdentityServicesInterface>;
|
||||||
|
|
||||||
|
// This identifier should be unique to the system.
|
||||||
|
fn aggregate_type() -> String {
|
||||||
|
"identity.employee".to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
// The aggregate logic goes here. Note that this will be the _bulk_ of a CQRS system
|
||||||
|
// so expect to use helper functions elsewhere to keep the code clean.
|
||||||
|
async fn handle(
|
||||||
|
&self,
|
||||||
|
command: Self::Command,
|
||||||
|
services: &Self::Services,
|
||||||
|
) -> Result<Vec<Self::Event>, Self::Error> {
|
||||||
|
match command {
|
||||||
|
IdentityCommand::EmployeeRegister(cmd) => Ok(vec![IdentityEvent::EmployeeRegistered(
|
||||||
|
services
|
||||||
|
.employee_register_service()
|
||||||
|
.register_employee(cmd)
|
||||||
|
.await?,
|
||||||
|
)]),
|
||||||
|
IdentityCommand::EmployeeInitLogin(cmd) => {
|
||||||
|
Ok(vec![IdentityEvent::EmployeeInitLoggedIn(
|
||||||
|
services.employee_login_service().init_login(cmd).await?,
|
||||||
|
)])
|
||||||
|
}
|
||||||
|
IdentityCommand::EmployeeFinishLogin(cmd) => Ok(vec![IdentityEvent::EmployeeLoggedIn(
|
||||||
|
services.employee_login_service().finish_login(cmd).await?,
|
||||||
|
)]),
|
||||||
|
IdentityCommand::EmployeeResendLoginOTP(cmd) => {
|
||||||
|
Ok(vec![IdentityEvent::ResentLoginOTP(
|
||||||
|
services
|
||||||
|
.employee_resend_login_otp_service()
|
||||||
|
.resend_otp(cmd)
|
||||||
|
.await?,
|
||||||
|
)])
|
||||||
|
}
|
||||||
|
IdentityCommand::EmployeeVerifyPhoneNumber(cmd) => {
|
||||||
|
Ok(vec![IdentityEvent::PhoneNumberVerified(
|
||||||
|
services
|
||||||
|
.employee_verify_phone_number_service()
|
||||||
|
.verify_phone_number(cmd)
|
||||||
|
.await?,
|
||||||
|
)])
|
||||||
|
}
|
||||||
|
IdentityCommand::EmployeeResendVerificationOTP(cmd) => {
|
||||||
|
Ok(vec![IdentityEvent::VerificationOTPResent(
|
||||||
|
services
|
||||||
|
.employee_resend_verification_otp_service()
|
||||||
|
.resend_otp(cmd)
|
||||||
|
.await?,
|
||||||
|
)])
|
||||||
|
}
|
||||||
|
IdentityCommand::EmployeeAcceptInvite(cmd) => Ok(vec![IdentityEvent::InviteAccepted(
|
||||||
|
services
|
||||||
|
.employee_accept_invite_service()
|
||||||
|
.accept_invite(cmd)
|
||||||
|
.await?,
|
||||||
|
)]),
|
||||||
|
IdentityCommand::EmployeeExitOrganization(cmd) => {
|
||||||
|
Ok(vec![IdentityEvent::OrganizationExited(
|
||||||
|
services
|
||||||
|
.employee_exit_organization_service()
|
||||||
|
.exit_organization(cmd)
|
||||||
|
.await?,
|
||||||
|
)])
|
||||||
|
}
|
||||||
|
|
||||||
|
_ => Ok(Vec::new()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn apply(&mut self, event: Self::Event) {
|
||||||
|
match event {
|
||||||
|
IdentityEvent::EmployeeRegistered(e) => {
|
||||||
|
*self = e.employee().clone();
|
||||||
|
}
|
||||||
|
IdentityEvent::EmployeeLoggedIn(e) => (),
|
||||||
|
IdentityEvent::EmployeeInitLoggedIn(e) => (),
|
||||||
|
IdentityEvent::ResentLoginOTP(e) => (),
|
||||||
|
IdentityEvent::PhoneNumberVerified(e) => self.phone_verified = true,
|
||||||
|
IdentityEvent::VerificationOTPResent(e) => (),
|
||||||
|
IdentityEvent::PhoneNumberChanged(e) => unimplemented!(),
|
||||||
|
IdentityEvent::InviteAccepted(e) => self.store_id = Some(*e.store_id()),
|
||||||
|
IdentityEvent::OrganizationExited(e) => self.store_id = None,
|
||||||
|
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use cqrs_es::test::TestFramework;
|
||||||
|
use employee_login_service::EmployeeLoginService;
|
||||||
|
|
||||||
|
use crate::identity::domain::{
|
||||||
|
employee_logged_in_event::{EmployeeInitLoggedInEvent, EmployeeLoggedInEvent}, employee_login_command::{EmployeeFinishLoginCommand, EmployeeInitLoginCommand}, employee_register_command::EmployeeRegisterCommand, employee_registered_event::EmployeeRegisteredEvent
|
||||||
|
};
|
||||||
|
use employee_register_service::EmployeeRegisterUserService;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
use crate::tests::bdd::*;
|
||||||
|
|
||||||
|
type EmployeeTestFramework = TestFramework<Employee>;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_register_employee() {
|
||||||
|
let cmd = EmployeeRegisterCommand::get_cmd();
|
||||||
|
let expected = EmployeeRegisteredEvent::get_event();
|
||||||
|
let expected = IdentityEvent::EmployeeRegistered(expected);
|
||||||
|
|
||||||
|
let mut services = MockIdentityServicesInterface::new();
|
||||||
|
services
|
||||||
|
.expect_employee_register_service()
|
||||||
|
.times(IS_CALLED_ONLY_ONCE.unwrap())
|
||||||
|
.return_const(EmployeeRegisterUserService::mock(
|
||||||
|
IS_CALLED_ONLY_ONCE,
|
||||||
|
cmd.clone(),
|
||||||
|
));
|
||||||
|
|
||||||
|
EmployeeTestFramework::with(Arc::new(services))
|
||||||
|
.given_no_previous_events()
|
||||||
|
.when(IdentityCommand::EmployeeRegister(cmd))
|
||||||
|
.then_expect_events(vec![expected]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// #[test]
|
||||||
|
// fn test_init_login() {
|
||||||
|
// let cmd = EmployeeInitLoginCommand::get_cmd();
|
||||||
|
// let expected = EmployeeInitLoggedInEvent::get_event();
|
||||||
|
// let expected = IdentityEvent::EmployeeInitLoggedIn(expected);
|
||||||
|
//
|
||||||
|
// let mut services = MockIdentityServicesInterface::new();
|
||||||
|
// services
|
||||||
|
// .expect_employee_login_service()
|
||||||
|
// .times(IS_CALLED_ONLY_ONCE.unwrap())
|
||||||
|
// .return_const(EmployeeLoginService::mock_init_login(
|
||||||
|
// IS_CALLED_ONLY_ONCE,
|
||||||
|
// cmd.clone(),
|
||||||
|
// ));
|
||||||
|
//
|
||||||
|
// EmployeeTestFramework::with(Arc::new(services))
|
||||||
|
// .given_no_previous_events()
|
||||||
|
// .when(IdentityCommand::EmployeeInitLogin(cmd))
|
||||||
|
// .then_expect_events(vec![expected]);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// #[test]
|
||||||
|
// fn test_finish_login() {
|
||||||
|
// let cmd = EmployeeFinishLoginCommand::get_cmd();
|
||||||
|
// let expected = EmployeeLoggedInEvent::get_event();
|
||||||
|
// let expected = IdentityEvent::EmployeeLoggedIn(expected);
|
||||||
|
//
|
||||||
|
// let mut services = MockIdentityServicesInterface::new();
|
||||||
|
// services
|
||||||
|
// .expect_employee_login_service()
|
||||||
|
// .times(IS_CALLED_ONLY_ONCE.unwrap())
|
||||||
|
// .return_const(EmployeeLoginService::mock_finish_login(
|
||||||
|
// IS_CALLED_ONLY_ONCE,
|
||||||
|
// cmd.clone(),
|
||||||
|
// ));
|
||||||
|
//
|
||||||
|
// EmployeeTestFramework::with(Arc::new(services))
|
||||||
|
// .given_no_previous_events()
|
||||||
|
// .when(IdentityCommand::EmployeeFinishLogin(cmd))
|
||||||
|
// .then_expect_events(vec![expected]);
|
||||||
|
// }
|
||||||
|
}
|
202
src/identity/domain/employee_commands.rs
Normal file
202
src/identity/domain/employee_commands.rs
Normal file
|
@ -0,0 +1,202 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
use commands::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd)]
|
||||||
|
pub enum EmployeeCommand {
|
||||||
|
Register(RegisterCommand),
|
||||||
|
Login(LoginCommand),
|
||||||
|
ResendLoginOTP(ResendLoginOTPCommand),
|
||||||
|
VerifyPhoneNumber(VerifyPhoneNumberCommand),
|
||||||
|
ResendVerificationOTP(ResendVerificationOTPCommand),
|
||||||
|
ChangePhoneNumber(ChangePhoneNumberCommand),
|
||||||
|
AcceptInvite(AcceptInviteCommand),
|
||||||
|
ExitOrganization(ExitOrganizationCommand),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod events {
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
use cqrs_es::DomainEvent;
|
||||||
|
|
||||||
|
// #[derive(
|
||||||
|
// Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
// )]
|
||||||
|
// pub struct EmployeeRegisteredEvent {
|
||||||
|
// employee: Employee,
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// #[derive(
|
||||||
|
// Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
// )]
|
||||||
|
// pub struct EmployeeLoggedInEvent {
|
||||||
|
// emp_id: Uuid,
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
|
||||||
|
// #[derive(
|
||||||
|
// Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
// )]
|
||||||
|
// pub struct ResentLoginOTPEvent {
|
||||||
|
// emp_id: Uuid,
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// #[derive(
|
||||||
|
// Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
// )]
|
||||||
|
// pub struct LoginOTPSentEvent {
|
||||||
|
// emp_id: Uuid,
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// #[derive(
|
||||||
|
// Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
// )]
|
||||||
|
// pub struct PhoneNumberVerifiedEvent {
|
||||||
|
// emp_id: Uuid,
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// #[derive(
|
||||||
|
// Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
// )]
|
||||||
|
// pub struct VerificationOTPResentEvent {
|
||||||
|
// emp_id: Uuid,
|
||||||
|
// }
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct VerificationOTPSentEvent {
|
||||||
|
emp_id: Uuid,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct PhoneNumberChangedEvent {
|
||||||
|
emp_id: Uuid,
|
||||||
|
phone_number: PhoneNumber,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct InviteAcceptedEvent {
|
||||||
|
emp_id: Uuid,
|
||||||
|
store_id: PhoneNumber,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct OrganizationExitedEvent {
|
||||||
|
emp_id: Uuid,
|
||||||
|
store_id: PhoneNumber,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd)]
|
||||||
|
pub enum EmployeeEvent {
|
||||||
|
EmployeeRegistered(EmployeeRegisteredEvent),
|
||||||
|
EmployeeLoggedIn(EmployeeLoggedInEvent),
|
||||||
|
ResentLoginOTP(ResentLoginOTPEvent),
|
||||||
|
PhoneNumberVerified(PhoneNumberVerifiedEvent),
|
||||||
|
VerificationOTPResent(VerificationOTPResentEvent),
|
||||||
|
PhoneNumberChanged(PhoneNumberChangedEvent),
|
||||||
|
InviteAccepted(InviteAcceptedEvent),
|
||||||
|
OrganizationExited(OrganizationExitedEvent),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DomainEvent for EmployeeEvent {
|
||||||
|
fn event_version(&self) -> String {
|
||||||
|
"1.0".to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn event_type(&self) -> String {
|
||||||
|
let e: &str = match self {
|
||||||
|
EmployeeEvent::EmployeeRegistered { .. } => "EmployeeRegistered",
|
||||||
|
EmployeeEvent::EmployeeLoggedIn { .. } => "EmployeeLoggedIn",
|
||||||
|
EmployeeEvent::ResentLoginOTP { .. } => "EmployeeResentLoginOTP",
|
||||||
|
EmployeeEvent::PhoneNumberVerified { .. } => "EmployeePhoneNumberVerified",
|
||||||
|
EmployeeEvent::VerificationOTPResent { .. } => "EmployeeVerificationOTPResent",
|
||||||
|
EmployeeEvent::PhoneNumberChanged { .. } => "EmployeePhoneNumberChanged",
|
||||||
|
EmployeeEvent::InviteAccepted { .. } => "EmployeeInviteAccepted",
|
||||||
|
EmployeeEvent::OrganizationExited { .. } => "EmployeeOrganizationExited",
|
||||||
|
};
|
||||||
|
|
||||||
|
e.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod commands {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct RegisterCommand {
|
||||||
|
first_name: String,
|
||||||
|
last_name: String,
|
||||||
|
emp_id: Uuid,
|
||||||
|
phone_number: PhoneNumber,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct AcceptInviteCommand {
|
||||||
|
emp_id: Uuid,
|
||||||
|
store_id: Uuid,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct ExitOrganizationCommand {
|
||||||
|
emp_id: Uuid,
|
||||||
|
store_id: Uuid,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct ChangePhoneNumberCommand {
|
||||||
|
phone_number: PhoneNumber,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct LoginCommand {
|
||||||
|
phone_number: PhoneNumber,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct ResendLoginOTPCommand {
|
||||||
|
phone_number: PhoneNumber,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct VerifyPhoneNumberCommand {
|
||||||
|
phone_number: PhoneNumber,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct ResendVerificationOTPCommand {
|
||||||
|
phone_number: PhoneNumber,
|
||||||
|
}
|
||||||
|
}
|
43
src/identity/domain/employee_logged_in_event.rs
Normal file
43
src/identity/domain/employee_logged_in_event.rs
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct EmployeeLoggedInEvent {
|
||||||
|
emp_id: Uuid,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct EmployeeInitLoggedInEvent {
|
||||||
|
emp_id: Uuid,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::utils::uuid::tests::UUID;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
impl EmployeeLoggedInEvent {
|
||||||
|
pub fn get_event() -> Self {
|
||||||
|
Self { emp_id: UUID }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EmployeeInitLoggedInEvent {
|
||||||
|
pub fn get_event() -> Self {
|
||||||
|
Self { emp_id: UUID }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
51
src/identity/domain/employee_login_command.rs
Normal file
51
src/identity/domain/employee_login_command.rs
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct EmployeeInitLoginCommand {
|
||||||
|
phone_number: PhoneNumber,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct EmployeeFinishLoginCommand {
|
||||||
|
phone_number: PhoneNumber,
|
||||||
|
otp: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
impl EmployeeInitLoginCommand {
|
||||||
|
|
||||||
|
pub fn get_cmd() -> Self {
|
||||||
|
Self {
|
||||||
|
phone_number: PhoneNumber::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl EmployeeFinishLoginCommand {
|
||||||
|
|
||||||
|
pub fn get_cmd() -> Self {
|
||||||
|
Self {
|
||||||
|
phone_number: PhoneNumber::default(),
|
||||||
|
otp: 999,
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
38
src/identity/domain/employee_register_command.rs
Normal file
38
src/identity/domain/employee_register_command.rs
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct EmployeeRegisterCommand {
|
||||||
|
first_name: String,
|
||||||
|
last_name: String,
|
||||||
|
emp_id: Uuid,
|
||||||
|
phone_number: PhoneNumber,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use crate::utils::uuid::tests::UUID;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
impl EmployeeRegisterCommand {
|
||||||
|
pub fn get_cmd() -> Self {
|
||||||
|
Self {
|
||||||
|
first_name: "foo".into(),
|
||||||
|
last_name: "foo".into(),
|
||||||
|
emp_id: UUID,
|
||||||
|
phone_number: PhoneNumber::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
39
src/identity/domain/employee_registered_event.rs
Normal file
39
src/identity/domain/employee_registered_event.rs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct EmployeeRegisteredEvent {
|
||||||
|
employee: Employee,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use crate::identity::domain::employee_register_command::EmployeeRegisterCommand;
|
||||||
|
|
||||||
|
impl EmployeeRegisteredEvent {
|
||||||
|
pub fn get_event() -> Self {
|
||||||
|
let cmd = EmployeeRegisterCommand::get_cmd();
|
||||||
|
let employee = EmployeeBuilder::default()
|
||||||
|
.first_name(cmd.first_name().clone())
|
||||||
|
.last_name(cmd.last_name().clone())
|
||||||
|
.emp_id(*cmd.emp_id())
|
||||||
|
.phone_number(cmd.phone_number().clone())
|
||||||
|
.phone_verified(false)
|
||||||
|
.deleted(false)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
Self { employee }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
src/identity/domain/exit_organization_command.rs
Normal file
18
src/identity/domain/exit_organization_command.rs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct ExitOrganizationCommand {
|
||||||
|
emp_id: Uuid,
|
||||||
|
store_id: Uuid,
|
||||||
|
}
|
19
src/identity/domain/invite_accepted_event.rs
Normal file
19
src/identity/domain/invite_accepted_event.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct InviteAcceptedEvent {
|
||||||
|
emp_id: Uuid,
|
||||||
|
invite_id: Uuid,
|
||||||
|
store_id: Uuid,
|
||||||
|
}
|
17
src/identity/domain/login_otp_sent_event.rs
Normal file
17
src/identity/domain/login_otp_sent_event.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct LoginOTPSentEvent {
|
||||||
|
emp_id: Uuid,
|
||||||
|
}
|
|
@ -3,3 +3,29 @@
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
pub mod aggregate;
|
pub mod aggregate;
|
||||||
|
pub mod employee_aggregate;
|
||||||
|
//pub mod employee_commands;
|
||||||
|
// pub mod store_aggregate;
|
||||||
|
// pub mod invite;
|
||||||
|
|
||||||
|
// events
|
||||||
|
pub mod employee_logged_in_event;
|
||||||
|
pub mod employee_registered_event;
|
||||||
|
pub mod invite_accepted_event;
|
||||||
|
pub mod login_otp_sent_event;
|
||||||
|
pub mod organization_exited_event;
|
||||||
|
pub mod phone_number_changed_event;
|
||||||
|
pub mod phone_number_verified_event;
|
||||||
|
pub mod resend_login_otp_event;
|
||||||
|
pub mod verification_otp_resent_event;
|
||||||
|
pub mod verification_otp_sent_event;
|
||||||
|
|
||||||
|
// commands
|
||||||
|
pub mod accept_invite_command;
|
||||||
|
pub mod change_phone_number_command;
|
||||||
|
pub mod employee_login_command;
|
||||||
|
pub mod employee_register_command;
|
||||||
|
pub mod exit_organization_command;
|
||||||
|
pub mod resend_login_otp_command;
|
||||||
|
pub mod resend_verification_otp_command;
|
||||||
|
pub mod verify_phone_number_command;
|
||||||
|
|
18
src/identity/domain/organization_exited_event.rs
Normal file
18
src/identity/domain/organization_exited_event.rs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct OrganizationExitedEvent {
|
||||||
|
emp_id: Uuid,
|
||||||
|
store_id: Uuid,
|
||||||
|
}
|
18
src/identity/domain/phone_number_changed_event.rs
Normal file
18
src/identity/domain/phone_number_changed_event.rs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct PhoneNumberChangedEvent {
|
||||||
|
emp_id: Uuid,
|
||||||
|
phone_number: PhoneNumber,
|
||||||
|
}
|
17
src/identity/domain/phone_number_verified_event.rs
Normal file
17
src/identity/domain/phone_number_verified_event.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct PhoneNumberVerifiedEvent {
|
||||||
|
emp_id: Uuid,
|
||||||
|
}
|
17
src/identity/domain/resend_login_otp_command.rs
Normal file
17
src/identity/domain/resend_login_otp_command.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct ResendLoginOTPCommand {
|
||||||
|
phone_number: PhoneNumber,
|
||||||
|
}
|
17
src/identity/domain/resend_login_otp_event.rs
Normal file
17
src/identity/domain/resend_login_otp_event.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct ResentLoginOTPEvent {
|
||||||
|
emp_id: Uuid,
|
||||||
|
}
|
17
src/identity/domain/resend_verification_otp_command.rs
Normal file
17
src/identity/domain/resend_verification_otp_command.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct ResendVerificationOTPCommand {
|
||||||
|
phone_number: PhoneNumber,
|
||||||
|
}
|
16
src/identity/domain/verification_otp_resent_event.rs
Normal file
16
src/identity/domain/verification_otp_resent_event.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct VerificationOTPResentEvent {
|
||||||
|
emp_id: Uuid,
|
||||||
|
}
|
17
src/identity/domain/verification_otp_sent_event.rs
Normal file
17
src/identity/domain/verification_otp_sent_event.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct VerificationOTPSentEvent {
|
||||||
|
emp_id: Uuid,
|
||||||
|
}
|
18
src/identity/domain/verify_phone_number_command.rs
Normal file
18
src/identity/domain/verify_phone_number_command.rs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use derive_builder::Builder;
|
||||||
|
use derive_getters::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::employee_aggregate::*;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Getters, Builder,
|
||||||
|
)]
|
||||||
|
pub struct VerifyPhoneNumberCommand {
|
||||||
|
phone_number: PhoneNumber,
|
||||||
|
otp: usize,
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ pub const IS_CALLED_ONLY_TWICE: Option<usize> = Some(2);
|
||||||
pub const IS_CALLED_ONLY_THRICE: Option<usize> = Some(3);
|
pub const IS_CALLED_ONLY_THRICE: Option<usize> = Some(3);
|
||||||
pub const IS_CALLED_ONLY_FOUR_TIMES: Option<usize> = Some(4);
|
pub const IS_CALLED_ONLY_FOUR_TIMES: Option<usize> = Some(4);
|
||||||
pub const RETURNS_RANDOM_STRING: &str = "test_random_string";
|
pub const RETURNS_RANDOM_STRING: &str = "test_random_string";
|
||||||
|
pub const RETURNS_RANDOM_NUMBER: usize = 10;
|
||||||
pub const IGNORE_CALL_COUNT: Option<usize> = None;
|
pub const IGNORE_CALL_COUNT: Option<usize> = None;
|
||||||
|
|
||||||
pub const RETURNS_TRUE: bool = true;
|
pub const RETURNS_TRUE: bool = true;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
pub mod parse_aggregate_id;
|
pub mod parse_aggregate_id;
|
||||||
|
pub mod random_number;
|
||||||
pub mod random_string;
|
pub mod random_string;
|
||||||
pub mod string;
|
pub mod string;
|
||||||
pub mod uuid;
|
pub mod uuid;
|
||||||
|
|
65
src/utils/random_number.rs
Normal file
65
src/utils/random_number.rs
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use actix_web::web;
|
||||||
|
use mockall::predicate::*;
|
||||||
|
use mockall::*;
|
||||||
|
#[cfg(test)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use tests::*;
|
||||||
|
|
||||||
|
pub type GenerateRandomNumberInterfaceObj = Arc<dyn GenerateRandomNumberInterface>;
|
||||||
|
pub type WebGenerateRandomNumberInterfaceObj = web::Data<GenerateRandomNumberInterfaceObj>;
|
||||||
|
|
||||||
|
#[automock]
|
||||||
|
pub trait GenerateRandomNumberInterface: Send + Sync {
|
||||||
|
fn get_random(&self, num_digits: u32) -> usize;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct GenerateRandomNumber;
|
||||||
|
impl GenerateRandomNumberInterface for GenerateRandomNumber {
|
||||||
|
fn get_random(&self, num_digits: u32) -> usize {
|
||||||
|
use rand::{rngs::ThreadRng, thread_rng, Rng};
|
||||||
|
|
||||||
|
let mut rng: ThreadRng = thread_rng();
|
||||||
|
|
||||||
|
let base: usize = 10;
|
||||||
|
rng.gen_range(0..base.pow(num_digits) - 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GenerateRandomNumber {
|
||||||
|
pub fn inject() -> impl FnOnce(&mut web::ServiceConfig) {
|
||||||
|
let g = WebGenerateRandomNumberInterfaceObj::new(Arc::new(GenerateRandomNumber));
|
||||||
|
let f = move |cfg: &mut web::ServiceConfig| {
|
||||||
|
cfg.app_data(g);
|
||||||
|
};
|
||||||
|
|
||||||
|
Box::new(f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_generate_random_number(
|
||||||
|
times: Option<usize>,
|
||||||
|
returning: usize,
|
||||||
|
) -> Arc<dyn GenerateRandomNumberInterface> {
|
||||||
|
let mut m = MockGenerateRandomNumberInterface::new();
|
||||||
|
|
||||||
|
if let Some(times) = times {
|
||||||
|
m.expect_get_random().times(times).return_const(returning);
|
||||||
|
} else {
|
||||||
|
m.expect_get_random().return_const(returning);
|
||||||
|
}
|
||||||
|
|
||||||
|
Arc::new(m)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue