home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
nrxsamp.zip
/
REG2.NRX
< prev
next >
Wrap
Text File
|
1997-08-13
|
2KB
|
77 lines
/*
* REG2.nrx -- accept and validate registration for access
* to private data
*
*/
class REG2
properties private static
UserList = '' -- valid user names array
NewUser = '' -- new user's userid
method main(s=String[]) static
UserList['mickey'] = 'ClubLeader' -- initialize some registered
UserList['minnie'] = 'mouseketeer' -- users
UserList['donald'] = 'aDuck'
loop forever
ThisUser = GetUser -- get this user's information
if ThisUser.left(1) = 'q' then leave -- user wants out
if ThisUser.left(3) = 'new' -- if new, sign them up
then do
Register
ThisUser = NewUser
end
if Validate(ThisUser) -- validate this user
then say "Access OK'd" -- let them in if OK
else say "Access denied"
end
/* Get user sign-on information */
method GetUser static
id = ''
pw = ''
say 'Userid ("new" to register; "q" to exit):'
id = ask
if id \= 'new' & id \= 'q' then do
say 'Password:'
pw = ask
end
return id'.'pw
/* Register a new user */
method Register static
say 'Choose a userid (it cannot be "new"):' -- prompt for userid
NewUser = ask
say 'Choose a password:' -- and password
pw1 = ask
say 'Re-enter password to verify:'
loop forever -- loop until password
pw2 = ask -- verified
if pw2 == pw1 then leave -- case-sensitive compare
say 'Verification failed; re-enter password'
end
UserList[NewUser] = pw1 -- add to "valid names" array
NewUser = NewUser'.'pw1
say 'Registration complete'
return
/* Validate a userid/password */
method Validate(userid) static returns boolean
parse userid id '.' pw
if UserList[id] \== pw then return 0 -- case-sensitive compare
else return 1