Fossil SCM

Prevent duplicate logins on the "user add" command. Also, allow the login to be specified on the command line.

drh 2007-10-26 18:18 UTC trunk
Commit 783df88ba84e919e1fef79aa0136342d978d5fbf
1 file changed +10 -2
+10 -2
--- src/user.c
+++ src/user.c
@@ -165,11 +165,11 @@
165165
**
166166
** %fossil user list
167167
**
168168
** List all users known to the repository
169169
**
170
-** %fossil user new
170
+** %fossil user new ?USERNAME?
171171
**
172172
** Create a new user in the repository. Users can never be
173173
** deleted. They can be denied all access but they must continue
174174
** to exist in the database.
175175
**
@@ -185,11 +185,19 @@
185185
}
186186
n = strlen(g.argv[2]);
187187
if( n>=2 && strncmp(g.argv[2],"new",n)==0 ){
188188
Blob passwd, login, contact;
189189
190
- prompt_user("login: ", &login);
190
+ if( g.argc>=4 ){
191
+ blob_zero(&login);
192
+ blob_append(&login, g.argv[3], -1);
193
+ }else{
194
+ prompt_user("login: ", &login);
195
+ }
196
+ if( db_exists("SELECT 1 FROM user WHERE login=%B", &login) ){
197
+ fossil_fatal("user %b already exists", &login);
198
+ }
191199
prompt_user("contact-info: ", &contact);
192200
prompt_for_password("password: ", &passwd, 1);
193201
db_multi_exec(
194202
"INSERT INTO user(login,pw,cap,info)"
195203
"VALUES(%B,%B,'jnor',%B)",
196204
--- src/user.c
+++ src/user.c
@@ -165,11 +165,11 @@
165 **
166 ** %fossil user list
167 **
168 ** List all users known to the repository
169 **
170 ** %fossil user new
171 **
172 ** Create a new user in the repository. Users can never be
173 ** deleted. They can be denied all access but they must continue
174 ** to exist in the database.
175 **
@@ -185,11 +185,19 @@
185 }
186 n = strlen(g.argv[2]);
187 if( n>=2 && strncmp(g.argv[2],"new",n)==0 ){
188 Blob passwd, login, contact;
189
190 prompt_user("login: ", &login);
 
 
 
 
 
 
 
 
191 prompt_user("contact-info: ", &contact);
192 prompt_for_password("password: ", &passwd, 1);
193 db_multi_exec(
194 "INSERT INTO user(login,pw,cap,info)"
195 "VALUES(%B,%B,'jnor',%B)",
196
--- src/user.c
+++ src/user.c
@@ -165,11 +165,11 @@
165 **
166 ** %fossil user list
167 **
168 ** List all users known to the repository
169 **
170 ** %fossil user new ?USERNAME?
171 **
172 ** Create a new user in the repository. Users can never be
173 ** deleted. They can be denied all access but they must continue
174 ** to exist in the database.
175 **
@@ -185,11 +185,19 @@
185 }
186 n = strlen(g.argv[2]);
187 if( n>=2 && strncmp(g.argv[2],"new",n)==0 ){
188 Blob passwd, login, contact;
189
190 if( g.argc>=4 ){
191 blob_zero(&login);
192 blob_append(&login, g.argv[3], -1);
193 }else{
194 prompt_user("login: ", &login);
195 }
196 if( db_exists("SELECT 1 FROM user WHERE login=%B", &login) ){
197 fossil_fatal("user %b already exists", &login);
198 }
199 prompt_user("contact-info: ", &contact);
200 prompt_for_password("password: ", &passwd, 1);
201 db_multi_exec(
202 "INSERT INTO user(login,pw,cap,info)"
203 "VALUES(%B,%B,'jnor',%B)",
204

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button