Sign in to follow this  
HankSteiner

Save Data Client side

Recommended Posts

Hey Guys,

So i want to create a autologin option in my login-form by saving username and pass in a file by javascript. My Question: is where can i save Data that stays after the User left the Server? i know i can use the Node.js Filesystem Module but before i try i ask the community.
my Form:

form.PNG

Thanks!

Hank

Share this post


Link to post
Share on other sites
Posted (edited)

If I ever go for such a system I wouldn't store names and passwords in files but match player IP and log them in if autologin option is enabled for the selected account. For players with dynamic IPs that would be a problem though.

The other solution is to generate a unique auth token and save it on the client. The token would link to player's account in the database and fetch the required data.

Client storage functions: https://wiki.rage.mp/index.php?title=Client-side_functions#Storage

 

Edited by Doom
  • Like 2

Share this post


Link to post
Share on other sites
On 6/10/2019 at 4:29 PM, Doom said:

If I ever go for such a system I wouldn't store names and passwords in files but match player IP and log them in if autologin option is enabled for the selected account. For players with dynamic IPs that would be a problem though.

The other solution is to generate a unique auth token and save it on the client. The token would link to player's account in the database and fetch the required data.

Client storage functions: https://wiki.rage.mp/index.php?title=Client-side_functions#Storage

 

I couldn't say it better.

 

The user is already bad at keeping his password secret and not using the same password he'll use on your server on more services (probably including mail and so on). Don't make it more bad for him by saving his password plain text on a file.

  • Like 1

Share this post


Link to post
Share on other sites
vor 20 Minuten schrieb robearded:

I couldn't say it better.

 

The user is already bad at keeping his password secret and not using the same password he'll use on your server on more services (probably including mail and so on). Don't make it more bad for him by saving his password plain text on a file.

Okey can some one give me a Hint on Client storage functions: https://wiki.rage.mp/index.php?title=Client-side_functions#Storage and some code? I am clueless and i think others would benefit from a example. i changed my login process by encrypting passwords using:

bcrypt.hash(pass, null, null, function(err, hash) {

and

bcrypt.compare(pass, sqlPassword, function(err, res2) {

at login. 

Thanks for the Response on this Thread!

Hank

  • Like 1

Share this post


Link to post
Share on other sites
7 hours ago, HankSteiner said:

Okey can some one give me a Hint on Client storage functions: https://wiki.rage.mp/index.php?title=Client-side_functions#Storage and some code? I am clueless and i think others would benefit from a example. i changed my login process by encrypting passwords using:

bcrypt.hash(pass, null, null, function(err, hash) {

and

bcrypt.compare(pass, sqlPassword, function(err, res2) {

at login. 

Thanks for the Response on this Thread!

Hank

https://wiki.rage.mp/index.php?title=Storage.flush()

You can find an example there, so basically you use "mp.storage.data.whateverYouWant = ..." to store the data and "mp.storage.flush()" to save the data from the RAM(temporary storage) to the actual disk (permanent storage), will be run automatically on disconnect, however it is recommended to call it yourself too either after adding some data to be saved either at a regular time because if the player game crashes I don't think it will be time for the automatically flush to run.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.