DEV Community

Cover image for Authentication system using rust (actix-web) and sveltekit - Login and Logout

Authentication system using rust (actix-web) and sveltekit - Login and Logout

John Owolabi Idogun on April 25, 2023

Introduction We have so far made efforts to register a user and save such user's data in our application. We then send a verification em...
Collapse
 
khannz profile image
Pavel Fiskovich • Edited

Hi there, @sirneij ! Great series, one of the best actually I saw for a long time... so huuge thanks for sharing!

I bet someone could already point that in other ways, but I can't see anything here, so let me gentle share my experience after reading this publication and repo code:

  1. for src/routes/users/login.rs it seems like pub visibility modifier is misplaced: I assume it should be at login_user(), not get_user_who_is_active() so we can use it for src/routes/users/mod.rs for example;
  2. with current code for login.rs, compiler is not happy about match of tokio::task::spawn_blocking(): Image description

Once again — thank you for such an effort 💯

Collapse
 
sirneij profile image
John Owolabi Idogun

Hi @khannz I am really humbled that you found my article useful.

To the reviews, the source code actually has some updated code, a bit different than the one in this article: github.com/Sirneij/rust-auth/blob/...

You can check it out.

Thank you once again.

Collapse
 
mrcigar profile image
Jay Jones

Hi John,

I'm trying to follow along as well and get stuck on the same login block:

cannot return value referencing local data loggedin_user.password
returns a value referencing data owned by the current function
login.rs(18, 59): loggedin_user.password is borrowed here
cannot return value referencing local data user
returns a value referencing data owned by the current function

The move for the loggedin_user to the blocking thread prevents us from returning the result of the password hash. I looked at the updated code and it looks to be the same. What am I missing?

Thanks for the help.
Jay.

Thread Thread
 
mrcigar profile image
Jay Jones

Nevermind,

For those stuck, Mario's post below was the solution, you have to update the password hashing function to not take ownership of the password during the check, see branch:
branch origin/confirm-login-session-logout

Thanks again for a great series.

Collapse
 
koakh profile image
Mário Monteiro

you are right @khannz! this series are pretty awesome,

I'm following the tutorial series right now and only fail here,
in this part of login and logout.....

I bring the files from repository branch origin/confirm-login-session-logout and keep going

congratulations for your awesome work @sirneij

Collapse
 
sirneij profile image
John Owolabi Idogun

Thank you @koakh