Function restapi::requests::user::consume_user_otp::consume_user_otp
source · [−]pub async fn consume_user_otp(
tracking_label: &str,
config: &CoreConfig,
db_pool: &Pool<PostgresConnectionManager<MakeTlsConnector>>,
kafka_pool: &KafkaPublisher,
headers: &HeaderMap<HeaderValue>,
bytes: &[u8]
) -> Result<Response<Body>, Infallible>
Expand description
consume_user_otp
Handles a user reseting their own password
with a one-time-use password token (otp
).
Overview Notes
A user can only have one record in the users_otp
table.
New password is salted using argon2
OTP tokens can only be used 1 time by a user.
Arguments
tracking_label
-&str
- caller logging labelconfig
-CoreConfig
db_pool
-Pool
- postgres client db threadpool with required tls encryptionkafka_pool
-KafkaPublisher
for asynchronously publishing messages to the connected kafka clusterheaders
-HeaderMap
- hashmap containing headers in key-value pairsRequest
’sBody
bytes
-&[u8]
- received bytes from the hyperRequest
’sBody
Returns
consume_user_otp on Success Returns
Creates a user in the db and generates a jwt for auth
hyper Response
containing a json-serialized
ApiResUserConsumeOtp
dictionary within the
Body
and a
200
HTTP status code
Ok(Response
)
Errors
consume_user_otp on Failure Returns
All errors return as a
hyper Response
containing a json-serialized
ApiResUserConsumeOtp
dictionary with a
non-200
HTTP status code
Err(Response
)