From 0981a71b87beb53427a57a82bc2086c76332165a Mon Sep 17 00:00:00 2001 From: Franklin Date: Thu, 21 Sep 2023 13:22:39 -0400 Subject: [PATCH] Readme info --- Readme.md | 12 +++++++++--- src/service/user.rs | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index bb5d869..4cdf241 100644 --- a/Readme.md +++ b/Readme.md @@ -9,6 +9,12 @@ This library is my attempt at developing a recyclable utility for different proj Setup: - Add this library to your Cargo.toml - Copy the migrations from the migrations folder inside this library into your migrations -- Add the user_lib::setup() function to your main. Make sure to pass it a PgPool -- Add the user_lib::routes to your actix_web server (register, authenticate, change_password, refresh_token) -Usage: \ No newline at end of file +- Run the migrations +Usage: +- A user can have many credentials (Currently only 3, one for each CredentialType: Username, Email, PhoneNumber) +- Register a user with `register_user().await` This function returns a Token that holds an Auth token that's usable for 7 days and a Refresh token in case the auth expires. +- Authenticate a user with their id and auth_token using `authenticate_user().await` +- If that's expired use `refresh_token().await` +- If you want another token then use `password_login().await` +- `reset_password().await` To reset password with current password +- `force_reset_password().await` To reset password without knowing the password (YOU MUST IMPLEMENT YOUR OWN WAY OF VALIDATING THAT USER'S IDENTITY) \ No newline at end of file diff --git a/src/service/user.rs b/src/service/user.rs index 1c323f9..66ec942 100644 --- a/src/service/user.rs +++ b/src/service/user.rs @@ -180,3 +180,8 @@ pub async fn authenticate_user(db_conn: &sqlx::PgPool, user: AuthenticateUserDto } } +pub async fn refresh_auth_token() {} + +pub async fn reset_password() {} + +pub async fn password_login() {} \ No newline at end of file