+=head2 register_validate
+
+Check whether or not a username is available.
+
+=cut
+
+sub register_validate :Local :Args(0) {
+ my ($self, $c) = @_;
+
+ my $id = $c->req->param('fieldId');
+ my $username = $c->req->param('fieldValue');
+
+ my $json_arr = [];
+
+ if ($username) {
+ my $account = $c->model('DB::Account')->find({username => $username});
+ if (!$account) {
+ $json_arr = ["$id", 1, "This username is available. Nice!"];
+ }
+ else {
+ $json_arr = ["$id", 0, "This username is taken."];
+ }
+ }
+ else {
+ $json_arr = ["$id", 0, "Invalid arguments to check script."];
+ }
+ $c->res->content_type("application/json");
+ $c->res->body(encode_json($json_arr));
+}
+
+=head2 access_denied
+
+Standard 403 error page
+
+=cut
+
+sub access_denied :Private {
+ my ($self, $c) = @_;
+ $c->res->body('Access denied.');
+ $c->res->status(403);
+}
+
+=head2 missing
+
+Standard 404 error page
+
+=cut
+
+sub missing :Private {
+ my ($self, $c) = @_;
+ $c->res->body('Page not found.');
+ $c->res->status(404);
+}
+