diff --git a/doc/index.html b/doc/index.html index 930460e..8020ee5 100644 --- a/doc/index.html +++ b/doc/index.html @@ -8,6 +8,9 @@
Peace::Controller::AccountVerification - Account verification controller.
+ +# This class is not to be used in Perl code.
+
+This class handles account verification from the web.
+ +Peace::Controller::AccountVerification implements the following methods.
+ +For internal usage.
+ +Recovers the Peace::Model::Developer associated from an identifier from database.
+$developer_dao->verify( verification_secret => $verification_secret );
+
+Verifies the developer by its verification_secret.
+Peace::DB, Peace::Model::Developer
diff --git a/lib/Peace.pm b/lib/Peace.pm index 55369b1..9b057ee 100644 --- a/lib/Peace.pm +++ b/lib/Peace.pm @@ -19,6 +19,8 @@ sub startup { $r->post('/developer')->to('developer#post'); $r->post('/developer/#identifier/application') ->to('application#developer_application_post'); + $r->get('/web/account-verification/#verification_secret') + ->to('account_verification#verify'); } sub peace_config { diff --git a/lib/Peace/Controller/AccountVerification.pm b/lib/Peace/Controller/AccountVerification.pm new file mode 100644 index 0000000..29cd84c --- /dev/null +++ b/lib/Peace/Controller/AccountVerification.pm @@ -0,0 +1,57 @@ +package Peace::Controller::AccountVerification; + +use Mojo::Base 'Mojolicious::Controller'; + +use v5.30.0; + +use strict; +use warnings; + +use Peace; +use Peace::DB; +use Peace::DAO::Developer; + +sub verify { + my $self = shift; + my $config = Peace->new->peace_config; + my $got_verification_secret = $self->stash->{verification_secret}; + my $dbh = Peace::DB->dbh( config => $config ); + my $developer_dao = Peace::DAO::Developer->new( dbh => $dbh ); + eval { + $developer_dao->verify( verification_secret => $got_verification_secret ); + }; + if ($@) { + $self->render( text => $@, status => '400' ); + return; + } + $self->render( text => 'Successfully verified.' ); +} +1; +=encoding utf8 + +=head1 NAME + +Peace::Controller::AccountVerification - Account verification controller. + +=head1 SYNOPSIS + + # This class is not to be used in Perl code. + +=head1 DESCRIPTION + +This class handles account verification from the web. + +=head1 METHODS + +Peace::Controller::AccountVerification implements the following methods. + +=head2 verify + +For internal usage. + +=head1 SEE ALSO + +L