DEV Community

Cover image for Authentication system using rust (actix-web) and sveltekit - Automated testing

Authentication system using rust (actix-web) and sveltekit - Automated testing

John Owolabi Idogun on May 05, 2023

Introduction We have come thus far. From a skeletal project to a feature-complete authentication system. Boldly, we can pat ourselves on...
Collapse
 
jaer profile image
jaer

Hi John,

Your code can't be compiled. Could you inform me how to run it?
The packages seem to be outdated.

Looking forward to your reply.
Thanks

Collapse
 
sirneij profile image
John Owolabi Idogun

Hi Jaer,

Can you explain more on this? I am very sure that some of the packages have latest revisions but I haven't had time to update them yet.

Collapse
 
jaer profile image
jaer

Hi John,

Thank you for replying.
Below is the snippet of the error output.
Appreciate if you could give me some hints on how to solve this issue. Thanks

error[E0433]: failed to resolve: unresolved import
--> src/routes/users/register.rs:64:24
|
64 | crate::types::ErrorResponse {
| ^^^^^
| |
| unresolved import
| help: a similar path exists:
sqlx::types`

error[E0433]: failed to resolve: unresolved import
--> src/routes/users/register.rs:68:24
|
68 | crate::types::ErrorResponse {
| ^^^^^
| |
| unresolved import
| help: a similar path exists: sqlx::types

error[E0433]: failed to resolve: unresolved import
--> src/routes/users/register.rs:81:72
|
81 | actix_web::HttpResponse::InternalServerError().json(crate::types::ErrorResponse {
| ^^^^^
| |
| unresolved import
| help: a similar path exists: sqlx::types

error[E0433]: failed to resolve: could not find utils in the crate root
--> src/routes/users/register.rs:87:12
|
87 | crate::utils::send_multipart_email(
| ^^^^^ could not find utils in the crate root

error[E0433]: failed to resolve: unresolved import
--> src/routes/users/register.rs:104:47
|
104 | actix_web::HttpResponse::Ok().json(crate::types::SuccessResponse {
| ^^^^^
| |
| unresolved import`

Thread Thread
 
sirneij profile image
John Owolabi Idogun • Edited

I just cloned the repo. Updated the packages using cargo update and my rust version using rust update. Everything compiles without any error. I have even pushed a small update to github.

Thread Thread
 
jaer profile image
jaer

Hi John,

Thanks for the highlight. But the issues during the compilation like this:

$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.75s
Running
target/debug/backend
thread 'main' panicked at /Users/eric/workspace/Rust/github/rust-auth/backend/src/startup.rs:111:54:
Failed to get AWS key.: NotPresent
note: run with
RUST_BACKTRACE=1environment variable to display a backtrace

Could you show me how to solve this issue?
Thanks

Thread Thread
 
sirneij profile image
John Owolabi Idogun

Kindly read what the error says. You need to provide your AWS S3 credentials. I included .env.test. It contains the required data. To run the app, create a .env.development file and put in the following data:

APP_EMAIL__HOST_USER=email@example.com
APP_EMAIL__HOST_USER_PASSWORD=some_email_password

AWS_REGION=some_region
AWS_ACCESS_KEY_ID=some_access_id
AWS_SECRET_ACCESS_KEY=some_access_key
AWS_S3_BUCKET_NAME=some_bucket_name

DATABASE_URL=postgres://postgres:password@localhost:5432/postgres
Enter fullscreen mode Exit fullscreen mode

Modify them accordingly.