Skip to content
Snippets Groups Projects
Verified Commit cb7069f8 authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Pridan user.secret

parent 228c4295
No related branches found
No related tags found
No related merge requests found
...@@ -69,6 +69,8 @@ sub startup { ...@@ -69,6 +69,8 @@ sub startup {
my $user = $c->schema->resultset('User')->find_or_create( my $user = $c->schema->resultset('User')->find_or_create(
$c->user, { key => 'uuid'} $c->user, { key => 'uuid'}
); );
$user->set_secret();
$c->stash->{user}{id} = $user->id; $c->stash->{user}{id} = $user->id;
return $c->$cb() if ! scalar @{ $scopes }; return $c->$cb() if ! scalar @{ $scopes };
......
...@@ -5,6 +5,8 @@ use warnings; ...@@ -5,6 +5,8 @@ use warnings;
use base 'DBIx::Class::Core'; use base 'DBIx::Class::Core';
use Data::Random qw(rand_chars);
our $VERSION = 1; our $VERSION = 1;
__PACKAGE__->table('users'); __PACKAGE__->table('users');
...@@ -20,6 +22,7 @@ __PACKAGE__->add_columns( ...@@ -20,6 +22,7 @@ __PACKAGE__->add_columns(
uuid uuid
is_active is_active
username username
secret
name name
main_group_name main_group_name
keepalive keepalive
...@@ -51,4 +54,18 @@ sub formatted { ...@@ -51,4 +54,18 @@ sub formatted {
} }
sub set_secret {
my $self = shift;
my $new = shift;
return if $self->secret and not $new;
my $secret = rand_chars( set => 'alphanumeric', size => 16 );
$self->update({
secret => $secret
});
}
1; 1;
...@@ -114,6 +114,8 @@ components: ...@@ -114,6 +114,8 @@ components:
type: string type: string
username: username:
type: string type: string
secret:
type: string
is_banned: is_banned:
type: boolean type: boolean
Announcement: Announcement:
......
...@@ -19,6 +19,7 @@ create table "users" ( ...@@ -19,6 +19,7 @@ create table "users" (
"uuid" varchar(36) not null, "uuid" varchar(36) not null,
"is_active" bool not null default 'true', "is_active" bool not null default 'true',
"username" text, "username" text,
"secret" text,
"name" text, "name" text,
"main_group_name" text, "main_group_name" text,
"keepalive" timestamp, "keepalive" timestamp,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment