Basic Ini login+registration system

By skitzkid on Dec 29, 2010

A quick, simple, beginner friendly snippet for ini based user registration/login management. I will expand this code when I have some spare time.

Usages:

  • Place code in remotes section of your script editor.
    Register: register password Login:login password

  • Note: These commands are only accessible via Private message/Query if you type it in a channel nothing will happen

Checking if a user is logged in example: if ($readini($+($1,.ini),info,loggedin) == true) { /notice $nick You Are Already Logged In | halt }

; Ini based registration/login system v0.1 by ares
; /register username password
alias register {
  writeini $($1,.ini) info password $2
  writeini $($1,.ini) info loggedin false
}
; /login username password
alias login {
  if ($readini($+($1,.ini),info,password) == $2) {
    writeini $($1,.ini) info loggedin true
    notice $1 You Have Successfully Logged In.
  }
}

on *:Text:`login*:?: {
  if (!$2) { /notice $nick Usage: `login password | halt }
  if ($readini($+($1,.ini),info,password) == $null) { notice $nick You have not registered. | halt }
  if ($readini($+($1,.ini),info,password) == false) { notice $nick You have not set a password. | halt }
  if ($readini($+($1,.ini),info,loggedin) == true) { notice $nick You Are Already Logged In | halt }
  login $nick $2
}
on *:Text:`register*:?: {
  if (!$2) { notice $nick Usage: `register password | halt }
  if ($readini($+($1,.ini),info,password) = !$null) { notice $nick Your already registered | halt }
  if ($2 = !$isalnum) { notice $nick Special characters are not supported. Characters Supported: a-z and 0 - 9 | halt }
  register $nick $2
  notice $nick You are now registered with the password: $2
}

Comments

Sign in to comment.
skitzkid   -  Dec 31, 2010

The reason I'm using a new ini file for each nick is for user administration purposes. It's a matter of personal preference, There's no difference using separate ini files, and its not hard to make the script store the user files in a separate directory for tidiness.

Thanks for comments, snippet updated
http://www.hawkee.com/snippet/8261/

 Respond  
Relurk_   -  Dec 30, 2010

It's alright, but you should advance it more so you can use commands such as

on 2:text:user command:#: {

and

on 3:text:admin command:#: {

This can be done with using guser and luser I believe.

Hmm, and it looks like you are writing a new ini for each user?
I would just do

writeini users.ini $nick $2

and

$readini(users.ini, $nick, password)

etc...
 Respond  
MashhitDK   -  Dec 29, 2010

Nice script I guess... ooO( Haven't tested it )
Could come in handy...
And nice work...

Maybe add a on part/quit logout

  • But then again... up to whoever uses and what it's used for.
 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.