Last active
April 12, 2020 23:00
-
-
Save pavelsr/ab24ac5972df2ac9b6983e3b501252f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# Demo of 'CSRF token validation failed' error | |
use Mojolicious::Lite; | |
use Mojo::SQLite; | |
helper sqlite => sub { | |
state $path = app->home->child( 'data.db' ); | |
state $sqlite = Mojo::SQLite->new( 'sqlite:' . $path ); | |
return $sqlite; | |
}; | |
app->sqlite->auto_migrate(1)->migrations->from_data; | |
plugin Yancy => { | |
backend => { Sqlite => app->sqlite }, | |
read_schema => 1 | |
}; | |
get '/' => sub { | |
my ( $c ) = @_; | |
$c->render( template => 'index'); | |
}; | |
app->routes->post( '/cu' )->to( 'yancy#set', schema => 'users' ); | |
app->start; | |
__DATA__ | |
@@ migrations | |
-- 1 up | |
CREATE TABLE users ( | |
id INTEGER NOT NULL PRIMARY KEY, | |
email VARCHAR UNIQUE, | |
is_admin BOOLEAN DEFAULT FALSE, | |
password VARCHAR | |
); | |
@@ index.html.ep | |
% layout 'default'; | |
% title 'Demo of issue #95'; | |
%= app->yancy->form->form_for( 'users', properties => [ qw/email password/ ], action => '/cu' ) | |
@@ layouts/default.html.ep | |
<!DOCTYPE html> | |
<html> | |
<head><title><%= title %></title></head> | |
<body><%= content %></body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment