Question
To add a new user's login and password from the registration form to the Users table, you are using the following code to transfer the password to the Users table:
=: insert(table: 'users'; field: 'login' = #name; field: 'pass' = $passenc; field: 'email' = #email; log: true)
passenc: strEncrypt(str: #password)
You created a file Crypto.key
in the directory /home/totum/totum-mit
for using the strEncrypt
function. The content of the file is the string "totum". Does it matter what is inside this file, or does it need to be written in a special way? A new entry appears in the Users table, but the new user cannot log into Totum with this password. When manually adding a new entry to the Users table, everything works correctly. What am I doing wrong?
Answer
User passwords in the Users table are stored as md5 hashes. When data is written to the users table via set, the string passed in the pass
field in unencrypted form is automatically converted to md5.
The correct action code for adding a user to the users table:
=: insert(table: 'users'; field: 'login' = #name; field: 'pass' = #password; field: 'email' = #email; log: true)