Jump to content

How to fix this warnings?


Andrew75t

Recommended Posts

Hello to all. I'm getting warnings like this, how can I fix them?

 

WARNING: S\admin_sys.lua:21: Access denied @ 'addAccount'
WARNING: S\admin_sys.lua:22: Bad argument @ 'setAccountData' [Expected account at argument 1, got nil]
WARNING: S\admin_sys.lua:38: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean]
WARNING: S\admin_sys.lua:39: Bad argument @ 'passwordVerify' [Expected string at argument 2, got boolean]
local MINIMUN_PASSWORD_LENGTH = 6

local function isPasswordValid(password)
	return string.len(password) >= MINIMUN_PASSWORD_LENGTH
end

addCommandHandler('reg', function (player, command, username, password)
	if not username or not password then
		return outputChatBox('SYNTAX: /' .. command .. ' [username][password]', player, 255, 255, 255)
	end
	
	if getAccount(username) then
		return outputChatBox('An account already exists with that name.', player, 255, 100, 100)
	end
	
	if not isPasswordValid(password) then
		return outputChatBox('The password supplied was not valid.', player, 255,100,100)
	end
	
	passwordHash(password, 'bcrypt', {}, function (hashedPassword) 
		local account = addAccount(username, hashedPassword)
		setAccountData(account, 'hashed_password', hashedPassword)
		outputChatBox('Your account has been successfully created! You may now login with /log', player, 100, 255, 100)
	end)
end, false, false)

addCommandHandler('log', function (player, command, username, password) 
	if not username or not password then
		return outputChatBox('SYNTAX: /' .. command .. ' [username] [password]', player, 255, 255, 255)
	end
	
	local account = getAccount(username)
	
	if not account then	
		outputChatBox('No such account could be found with that username or password.', player, 255, 100,100)
	end
	
	local hashedPassword = getAccountData(account, 'hashed_password')
	passwordVerify(password, hashedPassword, function (isValid)
		if not isValid then
			return outputChatBox('No such account could be found with that username or password.', player, 255, 100,100)
		end
		
		if logIn(player, account, hashedPassword) then
			return outputChatBox('You have successfully logged in!', player, 100,255,100)
		end

		return outputChatBox('An unknown error occured while attempting to authenticate.', player, 255, 100, 100)
	end)

end, false, false)

 

Edited by Andrew75t
Link to comment
  • Moderators

The main problem is this: WARNINGAccess denied @ 'addAccount'
You need to give permission to the resource to create accounts.

1) Stop the server.
2) Open ACL.xml
3) Find Admin group. ("<group name="Admin"> ...")
4) Add your resource to this group. (Add this line before </group> close tag: "<object name="resource.S"></object>")
    (if the resource's name is S)

<group name="Admin">
    <acl name="Moderator"></acl>
    <acl name="SuperModerator"></acl>
    <acl name="Admin"></acl>
    <acl name="RPC"></acl>
    <object name="resource.S"></object>
</group>

 

Edited by Patrick
  • Thanks 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...