added start page
|
1 |
<% |
improved password encrypt sy...
|
2 |
# API |
3 |
my $api = gitprep_api; |
|
added start page
|
4 |
|
revert encoding support
|
5 |
my $admin_user = app->manager->admin_user; |
Can't access _start page aft...
|
6 |
if (defined $admin_user && $admin_user ne '') { |
7 |
$self->redirect_to('/'); |
|
8 |
return; |
|
9 |
} |
|
10 |
|
|
improved password encrypt sy...
|
11 |
# Operator |
added start page
|
12 |
my $op = param('op') || ''; |
13 |
|
|
14 |
my $errors; |
|
15 |
if ($op eq 'create') { |
|
16 |
|
|
cleanup _start page validati...
|
17 |
# Parameters |
18 |
my $password = param('password'); |
|
19 |
my $password2 = param('password2'); |
|
20 |
|
|
21 |
# Validator |
|
22 |
my $vc = app->vc; |
|
23 |
|
|
24 |
# Validation |
|
25 |
my $validation = $vc->validation; |
|
26 |
|
|
27 |
# "user" |
|
28 |
if (defined $admin_user) { |
|
29 |
$validation->add_failed('Admin user already exists.'); |
|
30 |
} |
|
31 |
|
|
32 |
# "password" |
|
33 |
if (!(defined $password && length $password)) { |
|
34 |
$validation->add_failed('Password is empty.'); |
|
35 |
} |
|
36 |
elsif (!$vc->check($password, 'ascii_graphic')) { |
|
37 |
$validation->add_failed("Password contains invalid character."); |
|
38 |
} |
|
39 |
elsif ($password ne $password2) { |
|
40 |
$validation->add_failed("Two password don't match."); |
|
41 |
} |
|
42 |
|
|
43 |
if ($validation->is_valid) { |
|
improved password encrypt sy...
|
44 |
|
cleanup _start page validati...
|
45 |
# Valida parameters |
46 |
my $new_user = {}; |
|
47 |
$new_user->{id} = 'admin'; |
|
48 |
$new_user->{admin} = 1; |
|
49 |
my ($password_encryped, $salt) = $api->encrypt_password($password); |
|
50 |
$new_user->{password} = $password_encryped; |
|
51 |
$new_user->{salt} = $salt; |
|
add empty password to _start...
|
52 |
$new_user->{email} = ''; |
cleanup _start page validati...
|
53 |
|
54 |
# Create admin user |
|
55 |
$self->app->dbi->model('user')->insert($new_user); |
|
56 |
|
|
57 |
# Redirect |
|
58 |
$self->flash(admin_user_created => 1); |
|
59 |
$self->redirect_to('/_login'); |
|
60 |
return; |
|
added start page
|
61 |
} |
cleanup _start page validati...
|
62 |
else { $errors = $validation->messages } |
added start page
|
63 |
} |
cleanup _start page validati...
|
64 | |
65 |
layout 'common', title => 'Start page'; |
|
added start page
|
66 |
%> |
67 | ||
68 | ||
improved password encrypt sy...
|
69 |
%= include '/include/header'; |
add need_login_always_option
|
70 |
<!-- Start page --> |
improved password encrypt sy...
|
71 |
<div class="container"> |
72 |
% if ($errors) { |
|
73 |
<div class="alert alert-error"> |
|
74 |
<button type="button" class="close" data-dismiss="alert">×</button> |
|
added start page
|
75 |
% for my $error (@$errors) { |
76 |
<div><%= $error %></div> |
|
77 |
% } |
|
78 |
</div> |
|
79 |
% } |
|
improve admin page design
|
80 |
<div class="topic1" style="text-align:center"><h3>Create Admin User</h3></div> |
81 |
<form class="user-form" action="<%= url_for->query(op => 'create') %>" method="post"> |
|
82 |
<div class="user-form-container"> |
|
83 |
<div> |
|
84 |
<div>User name</div> |
|
85 |
<div style="margin-bottom:10px;"> |
|
improved password encrypt sy...
|
86 |
<b>admin</b> |
87 |
</div> |
|
88 |
</div> |
|
improve admin page design
|
89 |
<div> |
90 |
<div>Password</div> |
|
91 |
<div> |
|
improved password encrypt sy...
|
92 |
<%= password_field 'password', id => 'input-password', placeholder => 'Password' %> |
93 |
<%= password_field 'password2', id => 'input-password', placeholder => 'Password Again' %> |
|
94 |
</div> |
|
95 |
</div> |
|
improve admin page design
|
96 |
<div> |
improve button design
|
97 |
<button type="submit" class="btn btn-green btn-new" style="margin-top:20px">Create Admin User</button> |
improved password encrypt sy...
|
98 |
</div> |
improve admin page design
|
99 |
</div> |
100 |
</form> |
|
added start page
|
101 |
</div> |
improved password encrypt sy...
|
102 | |
103 |
%= include '/include/footer'; |