feat: admin-set passwords for staff, and a secure temporary-password generator
Creating a user takes the first password from the admin, and a new
POST /api/admin/users/{id}/password lets an admin set a temporary password
for another active user. Both store the bcrypt hash with login = N, so the
user must choose their own password at the next sign-in. No email is sent.
The password must match its confirmation and pass the admin password rules.
The emailed-password generator now draws from SecureRandom.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
1 parent
b49c9f1bc3
commit
2c0a847b68
12 files changed
+386
-15
No files matched your search
@@ -290,13 +290,12 @@ public class ValidateUtil {
|
||||
* Random Password String
|
||||
* Excluded 1 (one), l (lion) O (capital O), o (small letter O), 0 (zero), I (Ice cream), i ( small letter i) , q (small letter Q) and Q (capital letter Q)
|
||||
* **/
|
||||
private static final java.security.SecureRandom PASSWORD_RANDOM = new java.security.SecureRandom();
|
||||
public String getRandomPasswordString(int length) {
|
||||
String SALTCHARS = "ABCDEFGHJKLMNPRSTUVWXYZabcdefghjkmnpqrstuvwyz23456789";
|
||||
StringBuilder salt = new StringBuilder();
|
||||
Random rnd = new Random();
|
||||
while (salt.length() < length) { // length of the random string.
|
||||
int index = (int) (rnd.nextFloat() * SALTCHARS.length());
|
||||
salt.append(SALTCHARS.charAt(index));
|
||||
salt.append(SALTCHARS.charAt(PASSWORD_RANDOM.nextInt(SALTCHARS.length())));
|
||||
}
|
||||
return salt.toString();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user