aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2012-01-21 15:26:47 -0500
committerEugeniy Mikhailov <evgmik@gmail.com>2012-01-21 15:26:47 -0500
commite359b1bf358e72c0c235857c3e5b7ff3586439a0 (patch)
treeab18a83b208ddde6d63b6ab6511966beed2c87c4
parentb3f3668b7fcc71ff180b55fb5c735bbc724dc710 (diff)
downloadGradeBook-e359b1bf358e72c0c235857c3e5b7ff3586439a0.tar.gz
GradeBook-e359b1bf358e72c0c235857c3e5b7ff3586439a0.zip
added Set_New_Password_Non_Web
-rwxr-xr-xGradeBook_lib.tcl33
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