Fossil SCM
Prevent duplicate logins on the "user add" command. Also, allow the login to be specified on the command line.
Commit
783df88ba84e919e1fef79aa0136342d978d5fbf
Parent
f4c30de75af105d…
1 file changed
+10
-2
+10
-2
| --- src/user.c | ||
| +++ src/user.c | ||
| @@ -165,11 +165,11 @@ | ||
| 165 | 165 | ** |
| 166 | 166 | ** %fossil user list |
| 167 | 167 | ** |
| 168 | 168 | ** List all users known to the repository |
| 169 | 169 | ** |
| 170 | -** %fossil user new | |
| 170 | +** %fossil user new ?USERNAME? | |
| 171 | 171 | ** |
| 172 | 172 | ** Create a new user in the repository. Users can never be |
| 173 | 173 | ** deleted. They can be denied all access but they must continue |
| 174 | 174 | ** to exist in the database. |
| 175 | 175 | ** |
| @@ -185,11 +185,19 @@ | ||
| 185 | 185 | } |
| 186 | 186 | n = strlen(g.argv[2]); |
| 187 | 187 | if( n>=2 && strncmp(g.argv[2],"new",n)==0 ){ |
| 188 | 188 | Blob passwd, login, contact; |
| 189 | 189 | |
| 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 | + } | |
| 191 | 199 | prompt_user("contact-info: ", &contact); |
| 192 | 200 | prompt_for_password("password: ", &passwd, 1); |
| 193 | 201 | db_multi_exec( |
| 194 | 202 | "INSERT INTO user(login,pw,cap,info)" |
| 195 | 203 | "VALUES(%B,%B,'jnor',%B)", |
| 196 | 204 |
| --- 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 |