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 {
my $user = $c->schema->resultset('User')->find_or_create(
$c->user, { key => 'uuid'}
);
$user->set_secret();
$c->stash->{user}{id} = $user->id;
return $c->$cb() if ! scalar @{ $scopes };
......
......@@ -5,6 +5,8 @@ use warnings;
use base 'DBIx::Class::Core';
use Data::Random qw(rand_chars);
our $VERSION = 1;
__PACKAGE__->table('users');
......@@ -20,6 +22,7 @@ __PACKAGE__->add_columns(
uuid
is_active
username
secret
name
main_group_name
keepalive
......@@ -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;
......@@ -114,6 +114,8 @@ components:
type: string
username:
type: string
secret:
type: string
is_banned:
type: boolean
Announcement:
......
......@@ -19,6 +19,7 @@ create table "users" (
"uuid" varchar(36) not null,
"is_active" bool not null default 'true',
"username" text,
"secret" text,
"name" text,
"main_group_name" text,
"keepalive" timestamp,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment