forked from lix-project/hydra
Store the account type ("hydra" or "persona") explicitly in the database
This commit is contained in:
parent
14b9b201e1
commit
36c961a376
|
@ -91,6 +91,7 @@ sub persona_login :Path('/persona-login') Args(0) {
|
||||||
{ username => $email
|
{ username => $email
|
||||||
, password => "!"
|
, password => "!"
|
||||||
, emailaddress => $email,
|
, emailaddress => $email,
|
||||||
|
, type => "persona"
|
||||||
});
|
});
|
||||||
$user = $c->find_user({ username => $email }) or die;
|
$user = $c->find_user({ username => $email }) or die;
|
||||||
}
|
}
|
||||||
|
@ -163,6 +164,7 @@ sub register :Local Args(0) {
|
||||||
, fullname => $fullName
|
, fullname => $fullName
|
||||||
, password => "!"
|
, password => "!"
|
||||||
, emailaddress => "",
|
, emailaddress => "",
|
||||||
|
, type => "hydra"
|
||||||
});
|
});
|
||||||
setPassword($user, $password);
|
setPassword($user, $password);
|
||||||
});
|
});
|
||||||
|
@ -245,7 +247,7 @@ sub edit_POST {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($c->stash->{params}->{submit} // "") eq "reset-password") {
|
if (($c->stash->{params}->{submit} // "") eq "reset-password") {
|
||||||
error($c, "This user's password cannot be reset.") if $user->password eq "!";
|
error($c, "This user's password cannot be reset.") if $user->type ne "hydra";
|
||||||
$c->stash->{json} = {};
|
$c->stash->{json} = {};
|
||||||
error($c, "No email address is set for this user.")
|
error($c, "No email address is set for this user.")
|
||||||
unless $user->emailaddress;
|
unless $user->emailaddress;
|
||||||
|
@ -274,7 +276,7 @@ sub edit_POST {
|
||||||
});
|
});
|
||||||
|
|
||||||
my $password = $c->stash->{params}->{password} // "";
|
my $password = $c->stash->{params}->{password} // "";
|
||||||
if ($user->password ne "!" && $password ne "") {
|
if ($user->type eq "hydra" && $password ne "") {
|
||||||
error($c, "You must specify a password of at least 6 characters.")
|
error($c, "You must specify a password of at least 6 characters.")
|
||||||
unless isValidPassword($password);
|
unless isValidPassword($password);
|
||||||
error($c, "The passwords you specified did not match.")
|
error($c, "The passwords you specified did not match.")
|
||||||
|
|
|
@ -61,6 +61,12 @@ __PACKAGE__->table("Users");
|
||||||
default_value: 0
|
default_value: 0
|
||||||
is_nullable: 0
|
is_nullable: 0
|
||||||
|
|
||||||
|
=head2 type
|
||||||
|
|
||||||
|
data_type: 'text'
|
||||||
|
default_value: 'hydra'
|
||||||
|
is_nullable: 0
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
__PACKAGE__->add_columns(
|
__PACKAGE__->add_columns(
|
||||||
|
@ -74,6 +80,8 @@ __PACKAGE__->add_columns(
|
||||||
{ data_type => "text", is_nullable => 0 },
|
{ data_type => "text", is_nullable => 0 },
|
||||||
"emailonerror",
|
"emailonerror",
|
||||||
{ data_type => "integer", default_value => 0, is_nullable => 0 },
|
{ data_type => "integer", default_value => 0, is_nullable => 0 },
|
||||||
|
"type",
|
||||||
|
{ data_type => "text", default_value => "hydra", is_nullable => 0 },
|
||||||
);
|
);
|
||||||
|
|
||||||
=head1 PRIMARY KEY
|
=head1 PRIMARY KEY
|
||||||
|
@ -176,8 +184,8 @@ Composing rels: L</projectmembers> -> project
|
||||||
__PACKAGE__->many_to_many("projects", "projectmembers", "project");
|
__PACKAGE__->many_to_many("projects", "projectmembers", "project");
|
||||||
|
|
||||||
|
|
||||||
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-14 15:46:29
|
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-11-05 10:22:03
|
||||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Hv9Ukqud0d3uIUot0ErKeg
|
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Gd8KwFcnVShZ/WihvwfgQw
|
||||||
|
|
||||||
my %hint = (
|
my %hint = (
|
||||||
columns => [
|
columns => [
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
<small>
|
<small>
|
||||||
<em><a href="http://nixos.org/hydra" target="_blank">Hydra</a> [% HTML.escape(version) %] (using [% HTML.escape(nixVersion) %]).</em>
|
<em><a href="http://nixos.org/hydra" target="_blank">Hydra</a> [% HTML.escape(version) %] (using [% HTML.escape(nixVersion) %]).</em>
|
||||||
[% IF c.user_exists %]
|
[% IF c.user_exists %]
|
||||||
You are signed in as <tt>[% HTML.escape(c.user.username) %]</tt>.
|
You are signed in as <tt>[% HTML.escape(c.user.username) %]</tt>[% IF c.user.type == 'persona' %] via Persona[% END %].
|
||||||
[% END %]
|
[% END %]
|
||||||
</small>
|
</small>
|
||||||
</footer>
|
</footer>
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
[% IF c.user_exists && c.user.password != '!' %]
|
[% IF c.user_exists && c.user.type == 'hydra' %]
|
||||||
<script>
|
<script>
|
||||||
$("#persona-signout").click(doLogout);
|
$("#persona-signout").click(doLogout);
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -128,7 +128,7 @@
|
||||||
</li>
|
</li>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<li>
|
<li>
|
||||||
<a href="[% c.uri_for('/login') %]">Sign in with a Hydra user name</a>
|
<a href="[% c.uri_for('/login') %]">Sign in with a Hydra account</a>
|
||||||
</li>
|
</li>
|
||||||
[% END %]
|
[% END %]
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
[% IF !create && user.password != '!' %]
|
[% IF !create && user.type == 'hydra' %]
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">Password</label>
|
<label class="control-label">Password</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
@ -101,7 +101,7 @@
|
||||||
<i class="icon-ok icon-white"></i>
|
<i class="icon-ok icon-white"></i>
|
||||||
[%IF create %]Create[% ELSE %]Apply changes[% END %]
|
[%IF create %]Create[% ELSE %]Apply changes[% END %]
|
||||||
</button>
|
</button>
|
||||||
[% IF !create && c.check_user_roles('admin') && user.password != '!' %]
|
[% IF !create && c.check_user_roles('admin') && user.type == 'hydra' %]
|
||||||
<button id="reset-password" type="submit" class="btn btn-warning" name="submit" value="reset-password">
|
<button id="reset-password" type="submit" class="btn btn-warning" name="submit" value="reset-password">
|
||||||
<i class="icon-trash icon-white"></i>
|
<i class="icon-trash icon-white"></i>
|
||||||
Reset password
|
Reset password
|
||||||
|
|
|
@ -9,7 +9,8 @@ create table Users (
|
||||||
fullName text,
|
fullName text,
|
||||||
emailAddress text not null,
|
emailAddress text not null,
|
||||||
password text not null, -- sha256 hash
|
password text not null, -- sha256 hash
|
||||||
emailOnError integer not null default 0
|
emailOnError integer not null default 0,
|
||||||
|
type text not null default 'hydra' -- either "hydra" or "persona"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
1
src/sql/upgrade-25.sql
Normal file
1
src/sql/upgrade-25.sql
Normal file
|
@ -0,0 +1 @@
|
||||||
|
alter table Users add column type text not null default 'hydra';
|
Loading…
Reference in a new issue