Naked Auth System - Updated 4/22/06

Platform:  mIRC
Published  Jun 15, 2005
Updated  Apr 22, 2006
This is a basic auth system with lots of aliases to make implementation easy. It is very flexible and has all of the core functions done for you; it is designed to be a scripter's resource for when they need a log in/log out system.<BR>It stores account info in a hash table called Accounts and keeps track of logins trough a separate hash table called Logins. Includes a bunch of popups to for the auth functions including toggling whether or not new accounts may be freely registered and an /authhelp command that tells you all of the aliases and such that are usable. alias authhelp {
echo $colour(info) -a * Naked Auth System, by LIQUID_NiTrO aka W-Unit
echo $colour(notice) -a * COMMAND LIST
echo $colour(info2) -a * SETPASS: Changes a user's password- /setpass <accountname> <newpassword>
echo $colour(info2) -a * REGISTER: Registers a new account- /register <accountname> <password> <accesslevel>
echo $colour(info2) -a * LOGOUT: Logs a user out- /logout <nickname>
echo $colour(info2) -a * LOCKACCT: Locks a user's account so they cannot log in- /lockacct <nickname|accountname>
echo $colour(info2) -a * UNLOCKACCT: Reverses the action of /lockacct- /unlockacct <nickname|accountname>
echo $colour(info2) -a * SETLVL: Changes a user's access level- /setlvl <accountname> <newlevel>
echo $colour(info2) -a * ACCTINFO: Displays all current accounts and the last nicknames to log into them- /acctinfo
echo $colour(info2) -a * ACCTINFO: Displays all of certain user's account info- /acctinfo <accountname>
echo $colour(notice) -a * IDENTIFIER LIST
echo $colour(info2) -a * loggedin: Returns the account name of a logged in user or 0- $chr(36) $+ loggedin(nickname)
echo $colour(info2) -a * password: Returns the password for an account- $chr(36) $+ password(accountname)
echo $colour(info2) -a * password: Returns the password for a logged in user given a nickname- $chr(36) $+ password(nickname).nick
echo $colour(info2) -a * alevel: Returns the access level of an account- $chr(36) $+ alevel(accountname)
echo $colour(info2) -a * alevel: Returns the access level for a logged in user given a nickname- $chr(36) $+ alevel(nickname).nick
echo $colour(info) -a * End of Command List
}
#registration on
ctcp *:REGISTER: {
if ( !$2 ) || ( !$3 ) {
ctcpreply $nick REGISTER Syntax Error: REGISTER accountname password
halt
}
if ( $hget(Accounts,$2) ) {
ctcpreply $nick REGISTER Err: Account Already Exists
halt
}
if ( $loggedin($nick) ) {
ctcpreply $nick REGISTER Err: You already have an account!
halt
}
if ( $len($2) < 5 ) {
ctcpreply $nick REGISTER Err: Account Names must be at least 5 characters long
halt
}
if ( $len($3) < 5 ) {
ctcpreply $nick REGISTER Err: Passwords must be at least 5 characters long
halt
}
if ( $2 !isalnum ) {
ctcpreply $nick REGISTER Err: Account Names must contain only alphanumeric keys
halt
}
if ( $chr(44) isin $3 ) {
ctcpreply $nick REGISTER Err: Please do not use comas in your password
halt
}
hadd Accounts $2 $+($3,$chr(44),$fulldate,$chr(44),$nick,$address,0,0)
if ( $comchan($nick,0) > 0 ) {
hadd Logins $nick $2
}
ctcpreply $nick REGISTER OK
notice $nick From now on you will need to log in using /ctcp $me login $2 $3
}
#registration end
alias register {
if ( !$1 ) || ( !$2 ) {
echo $colour(info) -a * Register: Syntax Error: REGISTER accountname password access
halt
}
if ( $hget(Accounts,$1) ) {
echo $colour(info) -a * Register: Err: Account Already Exists
halt
}
if ( $loggedin($nick) ) {
echo $colour(info) -a * Register: Err: You already have an account!
halt
}
if ( $len($1) < 5 ) {
echo $colour(info) -a * Register: Err: Account Names must be at least 5 characters long
halt
}
if ( $len($2) < 5 ) {
echo $colour(info) -a * Register: Err: Passwords must be at least 5 characters long
halt
}
if ( $1 !isalnum ) {
echo $colour(info) -a * Register: Err: Account Names must contain only alphanumeric keys
halt
}
if ( $chr(44) isin $2 ) {
echo $colour(info) -a * Register: Err: Please do not use comas in your password
halt
}
if ( $3 !isnum ) && ( $3 ) {
echo $colour(info) -a * Register: Err: Access Level must be a number.
halt
}
hadd Accounts $1 $+($2,$chr(44),$fulldate,$chr(44),0,$chr(44),0,$chr(44),$iif($3,$3,0),0)
echo $colour(info) -a * Register: OK
}
alias loggedin {
;$loggedin(nickname)
if ( !$isid ) { halt }
elseif ( $hget(Logins,$1) ) { return $hget(Logins,$1) }
else { return 0 }
}
alias setpass {
;/setpass <accountname> <newpassword>
if ( !$hget(Accounts,$1) ) {
echo $colour(info) -a * $1 No Such Account
halt
}
if ( $len($2) < 5 ) {
echo $colour(info) -a * Setpass: Err: Passwords must be at least 5 characters long
halt
}
if ( $chr(44) isin $2 ) {
echo $colour(info) -a * Setpass: Err: Please do not use comas in your password
halt
}
hadd Accounts $1 $reptok($hget(Accounts,$1),1,$2,44)
echo $colour(info) -a * Changed $1 $+ 's password to $2
}
alias password {
;$password(nickname).nick
;$password(accoutname)
if ( !$isid ) { halt }
elseif ( $prop == nick ) {
if ( $hget(Logins,$1) ) {
return $gettok($hget(Accounts,$hget(Logins,$1)),1,44)
}
else {
return 0
}
}
else {
return $gettok($hget(Accounts,$1),1,44)
}
}
alias alevel {
;$alevel(nickname).nick
;$alevel(accountname)
if ( !$isid ) { halt }
elseif ( $prop == nick ) {
if ( $hget(Logins,$1) ) {
return $gettok($hget(Accounts,$hget(Logins,$1),5,44)
}
else {
return 0
}
}
else {
return $gettok($hget(Accounts,$1),6,44)
}
}
alias logout {
;/logout <nickname>
if ( !$loggedin($1) ) {
echo $colour(info) -a * $1 is not logged in!
halt
}
hdel Logins $1
echo $colour(info) -a * Logged $1 out
notice $nick You have been logged out.
}
alias lockacct {
;/lockacct <nickname|accountname>
if ( !$hget(Logins,$1) ) {
if ( $hget(Accounts,$1) ) {
hadd Accounts $1 $gettok($hget(Accounts,$1),1-5,44) $+ ,1
if ( $loggedin($gettok($hget(Accounts,$1),3,44)) ) {
logout $gettok($hget(Accounts,$1),3,44)
notice $gettok($hget(Accounts,$1),3,44) Your account has been locked.
}
echo $colour(info) -a * Locked Account $1
}
else {
echo $colour(info) -a * $1 No Such Nick/Account
}
halt
}
hadd Accounts $loggedin($1) $gettok($hget(Accounts,$loggedin($1)),1-5,44) $+ ,1
logout $1
notice $1 Your account has been locked.
echo $colour(info) -a * Locked Account $loggedin($1)
}
alias unlockacct {
;/unlockacct <nickname|accountname>
if ( !$hget(Logins,$1) ) {
if ( $hget(Accounts,$1) ) {
if ( !$gettok($hget(Accounts,$1),6,44) ) {
echo $colour(info) -a * That account is not locked!
halt
}
hadd Accounts $1 $gettok($hget(Accounts,$1),1-5,44) $+ ,0
echo $colour(info) -a * UnLocked Account $1
}
else {
echo $colour(info) -a * $1 No Such Nick/Account
}
halt
}
if ( !$gettok($hget(Accounts,$loggedin($1)),6,44) ) {
echo $colour(info) -a * That account is not locked!
halt
}
hadd Accounts $loggedin($1) $gettok($hget(Accounts,$loggedin($1)),1-5,44) $+ ,0
echo $colour(info) -a * UnLocked Account $loggedin($1)
}
alias setlvl {
;/setlvl <accountname> <level>
if ( !$hget(Accounts,$1) ) {
echo $colour(info) -a * $1 No Such Account Name
halt
}
if ( $2 !isnum ) {
echo $colour(info) -a * $2 is not a valid access level
halt
}
hadd Accounts $1 $reptok($hget(Accounts,$1),5,$2,44)
echo $colour(info) -a * Changed $1 $+ 's access level to $2
}
alias acctinfo {
;/acctinfo
;/acctinfo <accountname>
if ( $hget(Accounts,$1) ) {
echo $colour(info) -a * Account Info for $1 $+ : $hget(Accounts,$1)
echo $colour(info) -a * Format: pass,registered,lastnick,lastaddr,accesslevel,locked
halt
}
elseif ( $1 ) {
echo $colour(info) -a * $1 No Such Account Name
halt
}
echo $colour(info) -a * Format: AccountName : LastNick
var %x = 1
while ( %x <= $hget(Accounts,0).item ) {
echo $colour(info) -a * $hget(Accounts,%x).item : $gettok($hget(Accounts,%x),3,44)
inc %x 1
}
}
alias islocked {
if ( $prop == nick ) {
return $gettok($hget(Accounts,$hget(Logins,$1)),6,44)
}
else {
return $gettok($hget(Accounts,$1)
}
}
ctcp *:LOGIN: {
if ( !$hget(Accounts,$2) ) {
ctcpreply $nick LOGIN Err: No Such Account
halt
}
elseif ( $islocked($2) ) {
ctcpreply $nick LOGIN Err: This account has been locked
halt
}
elseif ( $comchan($nick,0) < 1 ) {
ctcpreply $nick LOGIN Err: You must be on at least 1 channel with me to log in
halt
}
elseif ( $password($2) !== $3 ) {
ctcpreply $nick LOGIN Err: Password Incorrect
halt
}
ctcpreply $nick LOGIN OK
hadd Logins $nick $2
hadd Accounts $reptok($hget(Accounts,$2),3,$nick,44)
hadd Accounts $reptok($hget(Accounts,$2),4,$address,44)
}
on *:PART:#: {
if ( $loggedin($nick) && $comchan($nick,0) == 1 ) {
hdel Logins $nick
notice $nick You have been logged out for security reasons.
}
}
on *:NICK: {
if ( $loggedin($nick) ) {
hadd Logins $newnick $hget(Logins,$nick)
hdel Logins $nick
}
}
alias -l gren {
if ( $group($1) == enabled ) {
return 1
}
else { return 0 }
}
on *:CONNECT: {
if ( !$hget(Logins) ) {
hmake Logins 50
}
}
on *:START: {
if ( $exists(Accounts.hsh) ) { hload Accounts Accounts.hsh }
else { hmake Accounts 100 }
}
on *:EXIT: {
hsave -o Accounts Accounts.dat
}
menu channel,status,query {
Auth System
.Register Account {
var %x = $input(Enter Account Name $+ $chr(44) Password $+ $chr(44) and Numeric Access Level $crlf Separated by a space,eq,Register an Account
if ( %x ) { register %x }
}
. $iif(!$hget(Logins),$style(2)) Log Someone Out {
var %x = $input(Enter Nickname of person to log out,eq,Logout)
if ( %x ) { logout %x }
}
.Retrieve Password
.. $iif(!$hget(Logins),$style(2)) By Nickname {
var %x = $input(Enter Nickname to Retrieve Password For,eq,Retrieve Password)
if ( %x ) { echo $colour(info2) -a * Password for %x $+ : $password(%x).nick }
}
..By Account Name {
var %x = $input(Enter Account Name to Retrieve Password For,eq,Retrieve Password)
if ( %x ) { echo $colour(info2) -a * Password for %x $+ : $password(%x) }
}
.Set Access Level {
var %x = $input(Enter Account Name to change access level for followed by the access level to change to $crlf separated by a space,eq,Change access level)
if ( %x ) { setlvl %x }
}
.Set Password {
var %x = $input(Enter Account Name to change password for followed by the password to change to $crlf separated by a space,eq,Change password)
if ( %x ) { setpass %x }
}
.Open Registration
.. $iif($gren(#registration),$style(1)) On:enable #registration | echo $colour(info) -a * Open Registration is now ON
.. $iif(!$gren(#registration),$style(1)) Off:disable #registration | echo $colour(info) -a * Open Registration is now OFF
}

Comments

Sign in to comment.
LIQUID_NiTrO   -  May 04, 2009
Clouds: Try restarting mIRC to make sure the on START event has executed. Or, if you added this script with the /load command, be sure you answer "Yes" to the dialog that should appear.
 Respond  
Clouds   -  Oct 06, 2007
It\'s bugged.

I tried making a new account, and I get this:

* /hadd: no such table \'Accounts\' (line 91, script5)
 Respond  
F*U*R*B*Y*   -  Jun 26, 2005
like geo said Nice job :)
 Respond  
xDaeMoN   -  Jun 16, 2005
You need to put it on your remote section. ( ALT-R -> FILE -> NEW )
 Respond  
scottyB   -  Jun 16, 2005
where do i copy it to?
 Respond  
supergeo   -  Jun 16, 2005
Nice job :)
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.