diff options
-rwxr-xr-x | GradeBook_lib.tcl | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index 7a28f38..a0e8a5f 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -1053,6 +1053,7 @@ proc GenPassword { } { } proc SendNewPassword2User { user password } { + dbg "Sending password to user $user" msg_level_info set CourseTitle [SelectItemFromCourseInfoTable course_title] set FirstName [SelectColValue4User FirstName $user] set tmp_msg_file /tmp/tmp_msg4user_$user @@ -1259,6 +1260,38 @@ proc ChooseNewPassword {db permission_list user } { puts "</div>" } +proc Set_New_Password_Non_Web {user newpassword} { + global GradebookServerConfig + if { $newpassword eq "" } { + dbg "Attempt to set empty password which is not permitted" msg_level_info + return + } + set password_hash [::md5::md5 -hex $newpassword] + + set err [catch { + sqlite3 pdb $GradebookServerConfig(passwords_db_file) + } errStat ] + if { $err } { + htmlErrorMsg "Problem accessing passwords database, please, contact system administrator" + dbg "$errStat with filename $GradebookServerConfig(passwords_db_file)" msg_level_critical + return + } + + if { ![ is_User_Registered_in_Passwords_DB $user ] } { + set sql_str [concat INSERT INTO PasswordsTable (UserName, PasswordHash) VALUES('$user', '$password_hash')] + } else { + set sql_str [concat UPDATE PasswordsTable SET \"PasswordHash\"=\'$password_hash\' where UserName=\"$user\"] + } + + set err [catch { + pdb eval $sql_str + } errStat ] + if { $err } { + htmlErrorMsg $errStat + dbg "the following error happen: $errStat" msg_level_warning + } +} + proc SetNewPassword {db permission_list user } { global script_name |