This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Luanub's profile picture

Login script/API with Multi Users and Permission[Updated v1.1]

Started by Luanub, 23 April 2012 - 12:14 AM
Luanub #1
Posted 23 April 2012 - 02:14 AM
I've been working on making an OS that will launch the programs that I have made for my server and and this is what I've came up with for the base scripting for my login functions.

This will be changed to play nice with the OS GUI so the menu's are nothing great currently.

The default password as well as the program that you want to launch after can be setup by editing the first couple of lines in the code.

It will automatically setup an admin account with the default password when you run the script and you can add users from there. Each new user will have the default password until it is changed.

The admin account will currently only take you into the admin menu, you will have to use another account to login the program.

I have added a new API that contains the functions used in the program, and now contains permissions. The program has not yet been updated to include permissions and I probably will not do that unless someone wants it done.

There are only 2 user types as that is all I have a need for, admin and user. See the instructions below on how to use them. If you would like more added let me know.

Here is a list of functions that you can call and example usage:
SpoilerloginMenu( user, pass )
usage: send user name and password to the function using in the two arguments, will return true if correct information is entered, false if not
example script:

	while true do
	shell.run("clear")
	write "Enter Username: "
	user = read()
	write "Enter Password: "
	pass = read("*")
	if login.loginMenu( user, pass) then
		nextFunction()
		break
	else
		print "Invalid Username/Password Entered"
	end
	end
	

adminPass()
usage: enters the password maintenance menu where you can reset passwords for users – admin only

adminUser()
usage: enteres the user maintenance menu where you can add/remove users – admin only

changePass()
usage: enters password change menu, this is for all users not just admins

checkPerms( user )
usage: returns the user type ie admin/user, returns nil if user not found

		if checkPerms("luanub") == "admin" then
		if checkPerms("luanub") == "user" then

Here is a demo of the API being used in my Shell that I'm currently working on:
Spoiler[media]http://youtu.be/8UVGLRaVpsA[/media]

Download Program: login Program
Download API v1.0: login API v1.0
Download API v1.1: login API v1.1 <– Current

If you are using v1.0 and upgrade to v1.1 you will need to modify your user files to match the new formatting.
–Example, original user file would contain admin,user1, now it contains {[0]="admin",[1]="user1",}

If you currently have the program you will need to rename either the Program or API as I uploaded them with the same name.

Let me know if there are any features you would like to see added or if you encounter any bugs. Any constructive criticism is welcome as well.
Edited on 01 May 2012 - 08:47 PM
Luanub #2
Posted 29 April 2012 - 06:47 AM
I've added a new API that will allow easier integration of this script into your programs, as well as a video that give a short demonstration of how the API works.

Oh feel free to modify this to where it will work best with your programs, just give credit where its deserved.
Luanub #3
Posted 01 May 2012 - 10:44 PM
Perms added, and other cleanup, read notes above.

This will probably be my final update here, the only work I have left is to customize the gui so it looks better inside my OS.

If you would like any enhancements done please contact me.