gitprep / templates / auto / _start.html.ep /
Newer Older
99 lines | 3.038kb
added start page
Yuki Kimoto authored on 2013-02-09
1
<%
improved password encrypt sy...
Yuki Kimoto authored on 2013-04-09
2
  # API
3
  my $api = gitprep_api;
added start page
Yuki Kimoto authored on 2013-02-09
4
  
revert encoding support
Yuki Kimoto authored on 2013-11-22
5
  my $admin_user = app->manager->admin_user;
Can't access _start page aft...
Yuki Kimoto authored on 2013-07-20
6
  if (defined $admin_user && $admin_user ne '') {
7
    $self->redirect_to('/');
8
    return;
9
  }
10
  
improved password encrypt sy...
Yuki Kimoto authored on 2013-04-09
11
  # Operator
added start page
Yuki Kimoto authored on 2013-02-09
12
  my $op = param('op') || '';
13
  
14
  my $errors;
15
  if ($op eq 'create') {
16
    
improved password encrypt sy...
Yuki Kimoto authored on 2013-04-09
17
    # Check existence admin user
revert encoding support
Yuki Kimoto authored on 2013-11-22
18
    my $admin_user = app->manager->admin_user;
added _start page tests
Yuki Kimoto authored on 2013-05-16
19
    if (defined $admin_user) { $errors = ['Admin user already exists.'] }
added start page
Yuki Kimoto authored on 2013-02-09
20
    else {
improved password encrypt sy...
Yuki Kimoto authored on 2013-04-09
21
      # Validation
22
      my $params = $api->params;
23
      my $rule = [
24
        password => [
added admin tests
Yuki Kimoto authored on 2013-05-16
25
          ['not_blank' => 'Password is empty.'],
added _start page tests
Yuki Kimoto authored on 2013-05-16
26
          ['ascii' => 'Password contains invalid character.'],
improved password encrypt sy...
Yuki Kimoto authored on 2013-04-09
27
          [{'length' => {max => 20}} => 'Password is too long.']
28
        ],
29
        {password_check => [qw/password password2/]}
30
          => {copy => 0}
31
          => [
added admin tests
Yuki Kimoto authored on 2013-05-16
32
            ['duplication' => "Two password don't match."]
improved password encrypt sy...
Yuki Kimoto authored on 2013-04-09
33
          ]
34
      ];
rename validator to vc to up...
Yuki Kimoto authored on 2013-12-02
35
      my $vresult = $self->app->vc->validate($params, $rule);
improved password encrypt sy...
Yuki Kimoto authored on 2013-04-09
36
      
37
      if ($vresult->is_ok) {
38
        
39
        # Valida parameters
40
        my $params = $vresult->data;
changed database column info...
Yuki Kimoto authored on 2013-04-17
41
        my $user = 'admin';
improved password encrypt sy...
Yuki Kimoto authored on 2013-04-09
42
        $params->{admin} = 1;
43
        my ($password_encryped, $salt)
44
          = $api->encrypt_password($params->{password});
45
        $params->{password} = $password_encryped;
46
        $params->{salt} = $salt;
47
        
48
        # Create admin user
changed database column info...
Yuki Kimoto authored on 2013-04-17
49
        $self->app->dbi->model('user')->insert($params, id => $user);
improved password encrypt sy...
Yuki Kimoto authored on 2013-04-09
50
        
51
        # Redirect
52
        $self->flash(admin_user_created => 1);
53
        $self->redirect_to('/_login');
added _start page tests
Yuki Kimoto authored on 2013-05-16
54
        return;
improved password encrypt sy...
Yuki Kimoto authored on 2013-04-09
55
      }
56
      else { $errors = $vresult->messages }
added start page
Yuki Kimoto authored on 2013-02-09
57
    }
58
  }
59
%>
60

            
add title
Yuki Kimoto authored on 2013-06-12
61
% layout 'common', title => 'Start page';
added start page
Yuki Kimoto authored on 2013-02-09
62

            
improved password encrypt sy...
Yuki Kimoto authored on 2013-04-09
63
  %= include '/include/header';
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
64
  <!-- Start page -->
improved password encrypt sy...
Yuki Kimoto authored on 2013-04-09
65
  <div class="container">
66
    % if ($errors) {
67
      <div class="alert alert-error">
68
        <button type="button" class="close" data-dismiss="alert">&times;</button>
added start page
Yuki Kimoto authored on 2013-02-09
69
        % for my $error (@$errors) {
70
          <div><%= $error %></div>
71
        % }
72
      </div>
73
    % }
improved password encrypt sy...
Yuki Kimoto authored on 2013-04-09
74
    <div class="text-center"><h3>Create Admin User</h3></div>
cleanup
Yuki Kimoto authored on 2013-05-13
75
    <div class="well" style="background:white;padding-top:15px;padding-left:60px;width:300px;margin-left:auto;margin-right:auto">
improved password encrypt sy...
Yuki Kimoto authored on 2013-04-09
76
      <form action="<%= url_for->query(op => 'create') %>" method="post">
77
        <div class="control-group">
78
          <label class="control-label" for="user-name">User name</label>
79
          <div>
80
            <b>admin</b>
81
          </div>
82
        </div>
83
        <div class="control-group">
84
          <label class="control-label" for="input-password">Password</label>
85
          <div class="controls">
86
            <%= password_field 'password', id => 'input-password', placeholder => 'Password' %>
87
            <%= password_field 'password2', id => 'input-password', placeholder => 'Password Again' %>
88
          </div>
89
        </div>
90
        <div class="control-group">
91
          <div class="controls">
92
            <button type="submit" class="btn">Create Admin User</button>
93
          </div>
94
        </div>
95
      </form>
96
    </div>
added start page
Yuki Kimoto authored on 2013-02-09
97
  </div>
improved password encrypt sy...
Yuki Kimoto authored on 2013-04-09
98

            
99
  %= include '/include/footer';