diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-01-25 12:56:00 -0500 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-01-25 12:56:00 -0500 |
commit | 5f524625f4fb3e6e1fdb370b0b6e0ca31c73822f (patch) | |
tree | da14ecd325b93cda2caf29c668042b1e35d1f425 /GradeBook_lib.tcl | |
parent | 69c5391df4353667b3e9aceb0f11de62658f41a7 (diff) | |
download | GradeBook-5f524625f4fb3e6e1fdb370b0b6e0ca31c73822f.tar.gz GradeBook-5f524625f4fb3e6e1fdb370b0b6e0ca31c73822f.zip |
added code for setting new password for logged on users
Ignore-this: aa7828b746baccd262546ef684250129
darcs-hash:20110125175600-067c0-0dde39efa23c8eaa79ae6d5c0dbe3b1f063cd4b5.gz
Diffstat (limited to 'GradeBook_lib.tcl')
-rwxr-xr-x | GradeBook_lib.tcl | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index 89a1190..ddd3e49 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -137,6 +137,8 @@ proc CreateAccessRightsTable {db} { AddAccessRightNonWeb updatecourseinfo 1 0 0 0 AddAccessRightNonWeb editnewuserinfo 1 0 0 0 AddAccessRightNonWeb addnewuserinfo 1 0 0 0 + AddAccessRightNonWeb choosenewpassword 1 1 1 0 + AddAccessRightNonWeb setnewpassword 1 1 1 0 } proc htmlErrorMsg { msg } { @@ -446,6 +448,9 @@ proc ChoseAction {action permission_list user} { editnewuserinfo { EditNewUserInfo db $permission_list $user } addnewuserinfo { AddNewUserInfo db $permission_list $user htmlDefaultView $permission_list $user } + choosenewpassword { ChooseNewPassword db $permission_list $user } + setnewpassword { SetNewPassword db $permission_list $user + htmlDefaultView $permission_list $user } defaultview { htmlDefaultView $permission_list $user } default { htmlErrorMsg "requested action <b>$action</b> is granted but not implemented yet" } } @@ -455,6 +460,40 @@ proc ChoseAction {action permission_list user} { } } +proc ChooseNewPassword {db permission_list user } { + global script_name + + puts "<div class=choosenewpassword>" + puts "<form name=\"input\" action=\"$script_name\" method=\"post\" />" + puts "Please type new password: <input type=\"password\" name=\"newpassword\" ><br>" + puts {<input type="hidden" name="action" value="setnewpassword"/>} + puts {<input type="submit" name="subaction" value="Submit" />} + puts {<input type="submit" name="subaction" value="Cancel" />} + puts {</form>} + puts "</div>" +} + +proc SetNewPassword {db permission_list user } { + global script_name + + set subaction [::ncgi::value subaction {}] + set newpassword [::ncgi::value newpassword {}] + + if { $subaction eq "Cancel" } { + return + } + + if { $newpassword eq "" } { + htmlErrorMsg "Empty passwords are not permitted" + return + } + + if { $subaction eq "Submit" } { + UpdateColValue4UserNameNonWeb PasswordHash $user [::md5::md5 -hex $newpassword] + } +} + + proc AddNewUserInfo {db permission_list user } { set subaction [::ncgi::value subaction {}] set first_name [::ncgi::value first_name {}] @@ -875,7 +914,7 @@ proc ShowControls { permission_list user } { global script_name dbg "outputing contol list" puts "<div class=\"controls\">" - set action_list [ list defaultview "Refresh" addcolumnrequest "Add Column" logoff "Logoff" editcourseinfo "Edit Course Info" editnewuserinfo "Add new user"] + set action_list [ list defaultview "Refresh" addcolumnrequest "Add Column" logoff "Logoff" editcourseinfo "Edit Course Info" editnewuserinfo "Add new user" choosenewpassword "Choose new password"] set separator { } foreach {act act_label} $action_list { if { [isActionGranted $act $permission_list $user] } { |