SetAccountPassword: Difference between revisions
Jump to navigation
Jump to search
m (fix new feature message) |
m (fix typo) |
||
Line 13: | Line 13: | ||
===Optional Arguments=== | ===Optional Arguments=== | ||
{{New feature/item|3.0151|1.5.1| | {{New feature/item|3.0151|1.5.1|7385|*'''passwordType:''' can be "plaintext", "sha256", or "md5"}} | ||
===Returns=== | ===Returns=== |
Revision as of 03:38, 1 August 2015
This function sets the password of the specified account.
Syntax
bool setAccountPassword ( account theAccount, string password[, string passwordType="plaintext"] )
OOP Syntax Help! I don't understand this!
- Method: account:setPassword(...)
- Variable: .password
Required Arguments
- theAccount: the account whose password you want to set
- password: the password
Optional Arguments
- passwordType: can be "plaintext", "sha256", or "md5"
Returns
Returns true if the password was set correctly, false otherwise.
Limits
Unless hashed with sha256 (length 97) or md5 (length 32), the following limits apply:
- Minimal account password length is 1 character.
- Maximum account password length is 30 characters.
- Account password can not be equal to "*****"
Example
This example allows a user to change their password with a command.
function ChangePlayerPassword(player, command, oldpass, newpass) -- get the account the player is currently logged into local account = getPlayerAccount(player) if (account) then -- if its only a guest account, do not allow the password to be changed if (isGuestAccount(account)) then outputChatBox("You must be logged into an account to change your password.", player) -- end the function return end -- check that the old password is correct local password_check = getAccount(getAccountName(account), oldpass) if (password_check) then -- check the length of the new password if (string.len(newpass)>=5) then setAccountPassword(account,newpass) else outputChatBox("Your new password must be at least 5 characters long.", player) end else outputChatBox("Old password invalid.", player) end end end addCommandHandler("changepass", ChangePlayerPassword)
See Also
- addAccount
- copyAccountData
- getAccount
- getAccountData
- getAccountName
- getAccountPlayer
- getAccountSerial
- getAccounts
- getAccountsBySerial
- getAllAccountData
- getPlayerAccount
- isGuestAccount
- logIn
- logOut
- removeAccount
- setAccountData
- setAccountPassword
- getAccountByID
- getAccountID
- getAccountIP
- getAccountsByData
- getAccountsByIP
- setAccountName