diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-03-31 01:36:18 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-03-31 01:36:18 +0800 |
commit | e351b2ea5d4261e9730f4a8f341c80e60a56d69a (patch) | |
tree | 73dacd76f4e85a7ff3c4c7d700b9d2f3e4c5d2f2 /mbbsd/user.c | |
parent | 8c0cc3c338c23e28ccbb20ac586f65a33d29f792 (diff) | |
download | pttbbs-e351b2ea5d4261e9730f4a8f341c80e60a56d69a.tar pttbbs-e351b2ea5d4261e9730f4a8f341c80e60a56d69a.tar.gz pttbbs-e351b2ea5d4261e9730f4a8f341c80e60a56d69a.tar.bz2 pttbbs-e351b2ea5d4261e9730f4a8f341c80e60a56d69a.tar.lz pttbbs-e351b2ea5d4261e9730f4a8f341c80e60a56d69a.tar.xz pttbbs-e351b2ea5d4261e9730f4a8f341c80e60a56d69a.tar.zst pttbbs-e351b2ea5d4261e9730f4a8f341c80e60a56d69a.zip |
- user (admin): change confirm order to prevent unnecessary alerts when admin aborts such operations (by watch@pttbug)
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4049 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/user.c')
-rw-r--r-- | mbbsd/user.c | 108 |
1 files changed, 69 insertions, 39 deletions
diff --git a/mbbsd/user.c b/mbbsd/user.c index 6ce507d7..739ab1e4 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -539,6 +539,7 @@ uinfo_query(userec_t *u, int adminmode, int unum) int ans; char buf[STRLEN]; char genbuf[200]; + char pre_confirmed = 0; int y = 0; int perm_changed; int mail_changed; @@ -861,12 +862,34 @@ uinfo_query(userec_t *u, int adminmode, int unum) fail++; break; } - } else { + } + if (!getdata(y++, 0, "請設定新密碼:", buf, PASSLEN, NOECHO)) { + outs("\n\n密碼設定取消, 繼續使用舊密碼\n"); + fail++; + break; + } + strlcpy(genbuf, buf, PASSLEN); + + move(y+1, 0); + outs("請注意設定密碼只有前八個字元有效,超過的將自動忽略。"); + + getdata(y++, 0, "請檢查新密碼:", buf, PASSLEN, NOECHO); + if (strncmp(buf, genbuf, PASSLEN)) { + outs("\n\n新密碼確認失敗, 無法設定新密碼\n"); + fail++; + break; + } + buf[8] = '\0'; + strlcpy(x.passwd, genpasswd(buf), sizeof(x.passwd)); + + // for admin mode, do verify after. + if (adminmode) + { FILE *fp; - char witness[3][32], title[100]; + char witness[3][IDLEN+1], title[100]; int uid; for (i = 0; i < 3; i++) { - if (!getdata(19 + i, 0, "請輸入協助證明之使用者:", + if (!getdata(y + i, 0, "請輸入協助證明之使用者:", witness[i], sizeof(witness[i]), DOECHO)) { outs("\n不輸入則無法更改\n"); fail++; @@ -882,50 +905,41 @@ uinfo_query(userec_t *u, int adminmode, int unum) outs("\n註冊未超過半年,請重新輸入\n"); i--; } - strcpy(witness[i], atuser.userid); - // Adjust upper or lower case + // Adjust upper or lower case + strlcpy(witness[i], atuser.userid, sizeof(witness[i])); } } - if (i < 3) + y += 3; + + if (i < 3 || fail > 0 || getans(msg_sure_ny) != 'y') + { + fail++; break; + } + pre_confirmed = 1; sprintf(title, "%s 的密碼重設通知 (by %s)",u->userid, cuser.userid); unlink("etc/updatepwd.log"); - if(! (fp = fopen("etc/updatepwd.log", "w"))) - break; + if(! (fp = fopen("etc/updatepwd.log", "w"))) + { + move(b_lines-1, 0); clrtobot(); + outs("系統錯誤: 無法建立通知檔,請至 " GLOBAL_BUGREPORT " 報告。"); + fail++; pre_confirmed = 0; + break; + } - fprintf(fp, "%s 要求密碼重設:\n" - "見證人為 %s, %s, %s", - u->userid, witness[0], witness[1], witness[2] ); - fclose(fp); + fprintf(fp, "%s 要求密碼重設:\n" + "見證人為 %s, %s, %s", + u->userid, witness[0], witness[1], witness[2] ); + fclose(fp); - post_file(GLOBAL_SECURITY, title, "etc/updatepwd.log", "[系統安全局]"); + post_file(GLOBAL_SECURITY, title, "etc/updatepwd.log", "[系統安全局]"); mail_id(u->userid, title, "etc/updatepwd.log", cuser.userid); for(i=0; i<3; i++) - { - mail_id(witness[i], title, "etc/updatepwd.log", cuser.userid); - } - y = 20; - } - - if (!getdata(y++, 0, "請設定新密碼:", buf, PASSLEN, NOECHO)) { - outs("\n\n密碼設定取消, 繼續使用舊密碼\n"); - fail++; - break; - } - strlcpy(genbuf, buf, PASSLEN); - - move(y+1, 0); - outs("請注意設定密碼只有前八個字元有效,超過的將自動忽略。"); - - getdata(y++, 0, "請檢查新密碼:", buf, PASSLEN, NOECHO); - if (strncmp(buf, genbuf, PASSLEN)) { - outs("\n\n新密碼確認失敗, 無法設定新密碼\n"); - fail++; - break; + { + mail_id(witness[i], title, "etc/updatepwd.log", cuser.userid); + } } - buf[8] = '\0'; - strlcpy(x.passwd, genpasswd(buf), sizeof(x.passwd)); break; case '3': @@ -947,8 +961,16 @@ uinfo_query(userec_t *u, int adminmode, int unum) char reason[STRLEN]; char title[STRLEN], msg[1024]; while (!getdata(b_lines-3, 0, "請輸入理由以示負責:", reason, 50, DOECHO)); - snprintf(title, sizeof(title), "刪除ID: %s (站長: %s)", x.userid, cuser.userid); - snprintf(msg, sizeof(msg), "帳號 %s 由站長 %s 執行刪除,理由:\n %s\n\n" + if (getans(msg_sure_ny) != 'y') + { + fail++; + break; + } + pre_confirmed = 1; + snprintf(title, sizeof(title), + "刪除ID: %s (站長: %s)", x.userid, cuser.userid); + snprintf(msg, sizeof(msg), + "帳號 %s 由站長 %s 執行刪除,理由:\n %s\n\n" "真實姓名:%s\n住址:%s\n認證資料:%s\nEmail:%s\n", x.userid, cuser.userid, reason, x.realname, x.address, x.justify, x.email); @@ -977,7 +999,15 @@ uinfo_query(userec_t *u, int adminmode, int unum) pressanykey(); return; } - if (getans(msg_sure_ny) == 'y') { + + if (!pre_confirmed) + { + if (getans(msg_sure_ny) != 'y') + return; + } + + // now confirmed. + if (1) { if (perm_changed) { post_change_perm(changefrom, x.userlevel, cuser.userid, x.userid); #ifdef PLAY_ANGEL |