commit:97cbb6cd2640bc3a0528dadb1730840ccae503c0
author:Chip Black
committer:Chip Black
date:Fri Feb 27 01:57:42 2015 -0600
parents:b152c3c669d496cc576b11bb04d71f9f492b2b8d
Add email status to backend
diff --git a/aux/cgi/email.cgi b/aux/cgi/email.cgi
line changes: +19/-0
index 0d128b9..62c717d
--- a/aux/cgi/email.cgi
+++ b/aux/cgi/email.cgi
@@ -4,6 +4,7 @@ use Digest::SHA qw/hmac_sha256_base64/;
 use Blerg::Database;
 use URI::Escape;
 use Mail::Message;
+use JSON;
 use strict;
 use v5.10;
 
@@ -141,6 +142,24 @@ EMAIL
 
             say '{"status": "success"}';
         }
+        when ('status') {
+            my $username = validate_authentication($q);
+            if (!defined $username) {
+                print_403;
+                next REQUEST;
+            }
+
+            my $email = undef;
+            my $email_conf_path = Blerg::Database::configuration->{data_path} . "/$username/email";
+            if (-f $email_conf_path) {
+                open CONF, $email_conf_path;
+                $email = <CONF>;
+                close CONF;
+            }
+
+            say header(-type => 'application/json'),
+                JSON->new->utf8->encode({email => $email});
+        }
         when ('cancel') {
             my $username = validate_authentication($q);
             if (!defined $username) {