diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2012-01-21 17:28:20 -0500 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2012-01-21 17:28:20 -0500 |
commit | 5786870ecc358e76dd33d71db267502ce9314ebb (patch) | |
tree | a1f9a57bc879208d307eadfe977856476bc9ab73 | |
parent | 9bf3802bd469521ba3850acde703a8e322eee776 (diff) | |
download | GradeBook-5786870ecc358e76dd33d71db267502ce9314ebb.tar.gz GradeBook-5786870ecc358e76dd33d71db267502ce9314ebb.zip |
added password table creation function and check if the user in table
-rwxr-xr-x | GradeBook_lib.tcl | 28 |
1 files changed, 28 insertions, 0 deletions
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 "</div>" } +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 |