diff options
-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 |