From 5786870ecc358e76dd33d71db267502ce9314ebb Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Sat, 21 Jan 2012 17:28:20 -0500 Subject: added password table creation function and check if the user in table --- GradeBook_lib.tcl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index fe3e987..51e682b 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -1807,6 +1807,34 @@ proc ShowControls { permission_list user } { puts "" } +proc Create_Passwords_Table {} { + dbg "Creating PasswordsTable" msg_level_info + set err [catch {pdb eval {CREATE TABLE PasswordsTable(UserName text, PasswordHash text)} } errStat] + if { $err } { + dbg "While creating PasswordsTable the following error happen: $errStat" msg_level_critical + } +} + +proc is_User_Registered_in_Passwords_DB { user_requested } { + set eval_str [list SELECT UserName FROM PasswordsTable WHERE UserName='$user_requested'] + set err [catch { + pdb eval $eval_str registered_user_names_array {} + } errStat ] + if { $err } { + if { $errStat eq "no such table: PasswordsTable" } { + Create_Passwords_Table + } else { + htmlErrorMsg "Problem accessing passwords database, please, contact system administrator" + dbg "$errStat" msg_level_warning + } + } + if { ![ info exist registered_user_names_array(UserName) ] } { + dbg "$user_requested does not exist in the passwords DB" msg_level_info + return false + } + return true +} + proc Authenticate_User { user_requested password } { #return __non_existing_user_ return $user_requested -- cgit v1.2.3