HankSteiner Posted June 10, 2019 Posted June 10, 2019 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: Thanks! Hank
Doom Posted June 10, 2019 Posted June 10, 2019 (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 June 10, 2019 by Doom 2
robearded Posted June 13, 2019 Posted June 13, 2019 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. 1
HankSteiner Posted June 13, 2019 Author Posted June 13, 2019 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 1
robearded Posted June 13, 2019 Posted June 13, 2019 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. 1
HankSteiner Posted June 15, 2019 Author Posted June 15, 2019 I managed to implement autologin! thanks @all Hank 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now