add name and mail column to user table. mail is require...
...d for user registration.
| ... | ... |
@@ -9,6 +9,7 @@ |
| 9 | 9 |
and move this feature to project settings page. |
| 10 | 10 |
- setup.sh is renamed to setup_module |
| 11 | 11 |
- separete database creating logic to setup_database script |
| 12 |
+ - add name and mail column to user table. mail is required for user registration. |
|
| 12 | 13 |
|
| 13 | 14 |
1.12 (7 Feb 2016) |
| 14 | 15 |
- Catch up latest Github design. |
| ... | ... |
@@ -1,8 +0,0 @@ |
| 1 |
-Copyright 2012-2013 Yuki Kimoto. All rights reserved. |
|
| 2 |
- |
|
| 3 |
-This program is free software; you can redistribute it and/or modify it |
|
| 4 |
-under the same terms of either: |
|
| 5 |
- |
|
| 6 |
- a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or |
|
| 7 |
- |
|
| 8 |
- b) the "Artistic License". |
| ... | ... |
@@ -446,6 +446,13 @@ If you install perl 5.10.1+ by perlbrew, you can install latest GitPrep. |
| 446 | 446 |
|
| 447 | 447 |
### I know information about GitPrep 2.0 upgrading. |
| 448 | 448 |
|
| 449 |
+You can upgrade GitPrep 2.0 the following command. |
|
| 450 |
+ |
|
| 451 |
+ ./setup_module |
|
| 452 |
+ ./setup_database |
|
| 453 |
+ |
|
| 454 |
+And you should know the following small changes. |
|
| 455 |
+ |
|
| 449 | 456 |
**1. X-Forwarded-HTTPS header is deprecated. use X-Forwarded-Proto header.** |
| 450 | 457 |
|
| 451 | 458 |
# This is deprecated in GitPrep 2.0 |
| ... | ... |
@@ -462,7 +469,7 @@ and move this feature to project settings page. |
| 462 | 469 |
# Go to settings page in your project |
| 463 | 470 |
/kimoto/gitprep/settings |
| 464 | 471 |
|
| 465 |
-**2. remove [basic]show_ignore_space_change_link option** |
|
| 472 |
+**3. remove [basic]show_ignore_space_change_link option** |
|
| 466 | 473 |
|
| 467 | 474 |
remove [basic]show_ignore_space_change_link option. |
| 468 | 475 |
but enable this feature on in project settings page. |
| ... | ... |
@@ -470,7 +477,7 @@ but enable this feature on in project settings page. |
| 470 | 477 |
# Go to settings page in your project |
| 471 | 478 |
/kimoto/gitprep/settings |
| 472 | 479 |
|
| 473 |
-**3. remove [basic]encoding_suspects option** |
|
| 480 |
+**4. remove [basic]encoding_suspects option** |
|
| 474 | 481 |
|
| 475 | 482 |
remove [basic]encoding_suspects option |
| 476 | 483 |
and move this feature to project settings page. |
| ... | ... |
@@ -478,6 +485,10 @@ and move this feature to project settings page. |
| 478 | 485 |
# Go to settings page in your project |
| 479 | 486 |
/kimoto/gitprep/settings |
| 480 | 487 |
|
| 488 |
+**5. mail is required for user registration. |
|
| 489 |
+ |
|
| 490 |
+mail address is require for user registration. |
|
| 491 |
+ |
|
| 481 | 492 |
## For Developer |
| 482 | 493 |
|
| 483 | 494 |
If you are a developer, you can start the application in development mode. |
| ... | ... |
@@ -311,6 +311,13 @@ create table user ( |
| 311 | 311 |
EOS |
| 312 | 312 |
$dbi->execute($sql); |
| 313 | 313 |
}; |
| 314 |
+ |
|
| 315 |
+ # Check mail column |
|
| 316 |
+ my $not_exists_user_mail; |
|
| 317 |
+ eval { $dbi->select('mail', table => 'user') };
|
|
| 318 |
+ if ($@) {
|
|
| 319 |
+ $not_exists_user_mail = 1; |
|
| 320 |
+ } |
|
| 314 | 321 |
|
| 315 | 322 |
# Create user columns |
| 316 | 323 |
my $user_columns = [ |
| ... | ... |
@@ -323,7 +330,7 @@ EOS |
| 323 | 330 |
for my $column (@$user_columns) {
|
| 324 | 331 |
eval { $dbi->execute("alter table user add column $column") };
|
| 325 | 332 |
} |
| 326 |
- |
|
| 333 |
+ |
|
| 327 | 334 |
# Check user table |
| 328 | 335 |
eval { $dbi->select([qw/row_id id admin password salt mail name/], table => 'user') };
|
| 329 | 336 |
if ($@) {
|
| ... | ... |
@@ -331,7 +338,20 @@ EOS |
| 331 | 338 |
$self->app->log->error($error); |
| 332 | 339 |
croak $error; |
| 333 | 340 |
} |
| 334 |
- |
|
| 341 |
+ |
|
| 342 |
+ # If mail is empty, id is copied to mail for uniqueness |
|
| 343 |
+ my $user_ids = $dbi->select('id', table => 'user', where => {mail => ''})->values;
|
|
| 344 |
+ for my $user_id (@$user_ids) {
|
|
| 345 |
+ $dbi->update({mail => "$user_id\@gitprep.example"}, table => 'user', where => {id => $user_id});
|
|
| 346 |
+ } |
|
| 347 |
+ |
|
| 348 |
+ # add unique to mail |
|
| 349 |
+ eval { $dbi->execute("create unique index user__mail on user(mail)") };
|
|
| 350 |
+ my $created_user_mail_index = $dbi->execute("select * from sqlite_master where type = 'index' and name = 'user__mail'")->one;
|
|
| 351 |
+ unless ($created_user_mail_index) {
|
|
| 352 |
+ croak "Can't create user__mail index"; |
|
| 353 |
+ } |
|
| 354 |
+ |
|
| 335 | 355 |
# Create ssh_public_key table |
| 336 | 356 |
eval {
|
| 337 | 357 |
my $sql = <<"EOS"; |
| ... | ... |
@@ -8,6 +8,8 @@ |
| 8 | 8 |
|
| 9 | 9 |
# Parameters |
| 10 | 10 |
my $id = param('id');
|
| 11 |
+ my $name = param('name');
|
|
| 12 |
+ my $mail = param('mail');
|
|
| 11 | 13 |
my $password = param('password');
|
| 12 | 14 |
my $password2 = param('password2');
|
| 13 | 15 |
|
| ... | ... |
@@ -34,6 +36,23 @@ |
| 34 | 36 |
} |
| 35 | 37 |
} |
| 36 | 38 |
|
| 39 |
+ # "name" check |
|
| 40 |
+ $name //= ''; |
|
| 41 |
+ |
|
| 42 |
+ # "mail" check |
|
| 43 |
+ if (!(defined $mail && length $mail)) {
|
|
| 44 |
+ $validation->add_failed(mail => "Mail must be not empty"); |
|
| 45 |
+ } |
|
| 46 |
+ elsif ($mail !~ /\@/) {
|
|
| 47 |
+ $validation->add_failed(mail => "Invalid mail address"); |
|
| 48 |
+ } |
|
| 49 |
+ else {
|
|
| 50 |
+ my $row = app->dbi->model('user')->select(where => {mail => $mail})->one;
|
|
| 51 |
+ if ($row) {
|
|
| 52 |
+ $validation->add_failed(id => "Mail $mail already exists"); |
|
| 53 |
+ } |
|
| 54 |
+ } |
|
| 55 |
+ |
|
| 37 | 56 |
# "password" check |
| 38 | 57 |
$password2 ||= ''; |
| 39 | 58 |
if (!(defined $password && length $password)) {
|
| ... | ... |
@@ -53,6 +72,8 @@ |
| 53 | 72 |
my $params = {};
|
| 54 | 73 |
$params->{password} = $password_encrypted;
|
| 55 | 74 |
$params->{salt} = $salt;
|
| 75 |
+ $params->{name} = $name;
|
|
| 76 |
+ $params->{mail} = $mail;
|
|
| 56 | 77 |
|
| 57 | 78 |
# Create user |
| 58 | 79 |
eval { app->manager->create_user($id, $params) };
|
| ... | ... |
@@ -96,9 +117,21 @@ |
| 96 | 117 |
<form class="user-form" action="<%= url_for->query(op => 'create') %>" method="post"> |
| 97 | 118 |
<div class="user-form-container"> |
| 98 | 119 |
<div> |
| 99 |
- <div>User name</div> |
|
| 120 |
+ <div>ID</div> |
|
| 121 |
+ <div> |
|
| 122 |
+ <%= text_field 'id', placeholder => 'ID' %> |
|
| 123 |
+ </div> |
|
| 124 |
+ </div> |
|
| 125 |
+ <div> |
|
| 126 |
+ <div>Name</div> |
|
| 127 |
+ <div> |
|
| 128 |
+ <%= text_field 'name', placeholder => 'Name' %> |
|
| 129 |
+ </div> |
|
| 130 |
+ </div> |
|
| 131 |
+ <div> |
|
| 132 |
+ <div>Mail</div> |
|
| 100 | 133 |
<div> |
| 101 |
- <%= text_field id => $id, placeholder => 'User', id =>'user-name'%> |
|
| 134 |
+ <%= text_field 'mail', placeholder => 'Mail' %> |
|
| 102 | 135 |
</div> |
| 103 | 136 |
</div> |
| 104 | 137 |
<div> |
| ... | ... |
@@ -40,7 +40,7 @@ note 'import_rep'; |
| 40 | 40 |
$t->content_like(qr/Admin/); |
| 41 | 41 |
|
| 42 | 42 |
# Create user |
| 43 |
- $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', password => 'a', password2 => 'a'});
|
|
| 43 |
+ $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', mail => 'kimoto@foo.com', password => 'a', password2 => 'a'});
|
|
| 44 | 44 |
$t->content_like(qr/Success.*created/); |
| 45 | 45 |
|
| 46 | 46 |
# Import repositories |
| ... | ... |
@@ -41,7 +41,7 @@ note 'Smart HTTP'; |
| 41 | 41 |
$t->content_like(qr/Admin/); |
| 42 | 42 |
|
| 43 | 43 |
# Create user |
| 44 |
- $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', password => 'a', password2 => 'a'});
|
|
| 44 |
+ $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', mail => 'kimoto@foo.com', password => 'a', password2 => 'a'});
|
|
| 45 | 45 |
$t->content_like(qr/Success.*created/); |
| 46 | 46 |
|
| 47 | 47 |
# Login as kimoto |
| ... | ... |
@@ -150,9 +150,9 @@ note 'Private repository and collaborator'; |
| 150 | 150 |
$t->content_like(qr/Admin/); |
| 151 | 151 |
|
| 152 | 152 |
# Create user |
| 153 |
- $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', password => 'a', password2 => 'a'});
|
|
| 153 |
+ $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', mail => 'kimoto@foo.com', password => 'a', password2 => 'a'});
|
|
| 154 | 154 |
$t->content_like(qr/Success.*created/); |
| 155 |
- $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto2', password => 'a', password2 => 'a'});
|
|
| 155 |
+ $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto2', mail => 'kimoto2@foo.com', password => 'a', password2 => 'a'});
|
|
| 156 | 156 |
$t->content_like(qr/Success.*created/); |
| 157 | 157 |
|
| 158 | 158 |
# Login as kimoto |
| ... | ... |
@@ -127,7 +127,7 @@ note 'Admin pages'; |
| 127 | 127 |
$t->content_like(qr/Two password/); |
| 128 | 128 |
|
| 129 | 129 |
# Create user |
| 130 |
- $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', password => 'a', password2 => 'a'});
|
|
| 130 |
+ $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', mail => 'kimoto@foo.com', password => 'a', password2 => 'a'});
|
|
| 131 | 131 |
$t->content_like(qr/Success.*created/); |
| 132 | 132 |
} |
| 133 | 133 |
|
| ... | ... |
@@ -163,7 +163,7 @@ note 'Admin pages'; |
| 163 | 163 |
note 'Delete user'; |
| 164 | 164 |
{
|
| 165 | 165 |
# Create user |
| 166 |
- $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto-tmp', password => 'a', password2 => 'a'});
|
|
| 166 |
+ $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto-tmp', mail => 'kimoto-tmp@foo.com', password => 'a', password2 => 'a'});
|
|
| 167 | 167 |
$t->content_like(qr/kimoto-tmp/); |
| 168 | 168 |
$t->get_ok('/_admin/users');
|
| 169 | 169 |
$t->content_like(qr/kimoto-tmp/); |
| ... | ... |
@@ -215,9 +215,9 @@ note 'Reset password'; |
| 215 | 215 |
$t->content_like(qr/Admin/); |
| 216 | 216 |
|
| 217 | 217 |
# Create user |
| 218 |
- $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto1', password => 'a', password2 => 'a'});
|
|
| 218 |
+ $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto1', mail => 'kimoto1@foo.com', password => 'a', password2 => 'a'});
|
|
| 219 | 219 |
$t->content_like(qr/kimoto1/); |
| 220 |
- $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto2', password => 'a', password2 => 'a'});
|
|
| 220 |
+ $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto2', mail => 'kimoto2@foo.com', password => 'a', password2 => 'a'});
|
|
| 221 | 221 |
$t->content_like(qr/kimoto2/); |
| 222 | 222 |
|
| 223 | 223 |
# Logout |
| ... | ... |
@@ -262,9 +262,9 @@ note 'Profile'; |
| 262 | 262 |
$t->post_ok('/_login?op=login', form => {id => 'admin', password => 'a'});
|
| 263 | 263 |
|
| 264 | 264 |
# Create user |
| 265 |
- $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto1', password => 'a', password2 => 'a'});
|
|
| 265 |
+ $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto1', mail => 'kimoto1@foo.com', password => 'a', password2 => 'a'});
|
|
| 266 | 266 |
$t->content_like(qr/kimoto1/); |
| 267 |
- $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto2', password => 'a', password2 => 'a'});
|
|
| 267 |
+ $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto2', mail => 'kimoto2@foo.com', password => 'a', password2 => 'a'});
|
|
| 268 | 268 |
$t->content_like(qr/kimoto2/); |
| 269 | 269 |
|
| 270 | 270 |
# Login as kimoto1 |
| ... | ... |
@@ -552,9 +552,9 @@ note 'Private repository and collaborator'; |
| 552 | 552 |
$t->content_like(qr/Admin/); |
| 553 | 553 |
|
| 554 | 554 |
# Create user |
| 555 |
- $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', password => 'a', password2 => 'a'});
|
|
| 555 |
+ $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', mail => 'kimoto@foo.com', password => 'a', password2 => 'a'});
|
|
| 556 | 556 |
$t->content_like(qr/Success.*created/); |
| 557 |
- $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto2', password => 'a', password2 => 'a'});
|
|
| 557 |
+ $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto2', mail => 'kimoto2@foo.com', password => 'a', password2 => 'a'});
|
|
| 558 | 558 |
$t->content_like(qr/Success.*created/); |
| 559 | 559 |
|
| 560 | 560 |
# Login as kimoto |