Mojolicious::Plugin::RoutesAuthDBI::Install
¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !
NAME
Mojolicious::Plugin::RoutesAuthDBI::Install - is a Mojolicious::Controller for installation instructions.
DB DESIGN DIAGRAM
See https://github.com/mche/Mojolicious-Plugin-RoutesAuthDBI/blob/master/Diagram.svg
Manual
$ read -d '' CODE <<PERL; perl -Ilib -e "$CODE" get /man
use Mojo::Base 'Mojolicious';
sub startup {
shift->routes->route('/man')
->to('install#manual', namespace=>'Mojolicious::Plugin::RoutesAuthDBI');
}
__PACKAGE__->new->start;
PERL
View schema (define the postgresql schema name and alternative tables names)
$ read -d '' CODE <<PERL; perl -Ilib -e "$CODE" get /schema/<name>[?...] # /schema/public?profiles=профили
use Mojo::Base 'Mojolicious';
sub startup {
shift->routes->route('/schema/:schema')
->to('Schema#schema', namespace=>'Mojolicious::Plugin::RoutesAuthDBI');
}
__PACKAGE__->new->start;
PERL
Apply schema (define the postgresql schema name and tables names)
$ read -d '' CODE <<PERL; perl -Ilib -e "$CODE" get /schema/<name>[?...] 2>/dev/null | psql -d <dbname> # /schema/<name>?roles=groups
use Mojo::Base 'Mojolicious';
sub startup {
shift->routes->route('/schema/:schema')
->to('Schema#schema', namespace=>'Mojolicious::Plugin::RoutesAuthDBI');
}
__PACKAGE__->new->start;
PERL
Sample app
$ read -d '' CODE <<PERL; perl -Ilib -e "$CODE" get /app 2>/dev/null > test-app.pl
use Mojo::Base 'Mojolicious';
sub startup {
shift->routes->route('/app')
->to('install#sampl_app', namespace=>'Mojolicious::Plugin::RoutesAuthDBI');
}
__PACKAGE__->new->start;
PERL
Define DBI->connect(...) and some plugin options in test-app.pl
Check list of admin routes:
$ perl test-app.pl routes
Start app
$ perl test-app.pl daemon
Trust url for admin-user creation:
$ perl test-app.pl get /<pluginconf->{admin}{prefix}>/<pluginconf->{admin}{trust}>/user/new/<new admin login>/<admin pass> 2>/dev/null
User will be created and assigned to role 'Admin' . Role 'Admin' assigned to namespace 'Mojolicious::Plugin::RoutesAuthDBI' that has access to all admin controller routes!
Sign in on browser
http://127.0.0.1:3000/sign/in/<new admin login>/<admin pass>