Make Account Center only usable when logged in
authorChip Black <bytex64@bytex64.net>
Mon, 2 Mar 2015 07:08:30 +0000 (01:08 -0600)
committerChip Black <bytex64@bytex64.net>
Mon, 2 Mar 2015 07:08:30 +0000 (01:08 -0600)
www/jssrc/blerg/AccountCenter.js
www/jssrc/blerg/EmailForm.js

index 766e9b2..981fcb1 100644 (file)
@@ -1,20 +1,5 @@
 enyo.kind({
     name: "blerg.AccountCenter",
-    components: [
-        {tag: 'h2', content: "Change Password"},
-        {kind: "blerg.PasswdForm"},
-        {tag: 'h2', content: "Email"},
-        {kind: 'blerg.EmailForm'},
-        {tag: 'h2', content: "Generate recovery link"},
-        {content: "A recovery link is a URL that will allow you to reset the password on your account at a later time. Whoever has this link will be able to gain control of your account. This link should be kept in a safe place like an encrypted password manager or a physical piece of paper locked in a safe. The link will expire after one year or the next password change (either via a recovery link or by changing it manually above). To indicate that you understand this, please copy <code>blërg</code> into the textbox below.", tag: 'p', allowHtml: true},
-        {tag: 'form', onsubmit: 'generateRecoveryLink', components: [
-            {kind: 'onyx.InputDecorator', classes: "recovery", components: [
-                {kind: 'onyx.Input', name: "recoveryVerifier"}
-            ]},
-            {kind: 'onyx.Button', content: "Generate", classes: "recovery", onclick: "generateRecoveryLink"}
-        ]},
-        {tag: 'p', name: 'recoveryLinkOutput', classes: 'recovery'}
-    ],
     statics: {
         locationDetect: function(l) {
             var m = l.hash.match(/^#\/account$/);
@@ -25,9 +10,32 @@ enyo.kind({
             }
         }
     },
+    handlers: {
+        onLogin: "loginStatusChange",
+        onLogout: "loginStatusChange"
+    },
+    components: [
+        {name: 'accountCenterContent', showing: false, components: [
+            {tag: 'h2', content: "Change Password"},
+            {kind: "blerg.PasswdForm"},
+            {tag: 'h2', content: "Email"},
+            {kind: 'blerg.EmailForm'},
+            {tag: 'h2', content: "Generate recovery link"},
+            {content: "A recovery link is a URL that will allow you to reset the password on your account at a later time. Whoever has this link will be able to gain control of your account. This link should be kept in a safe place like an encrypted password manager or a physical piece of paper locked in a safe. The link will expire after one year or the next password change (either via a recovery link or by changing it manually above). To indicate that you understand this, please copy <code>blërg</code> into the textbox below.", tag: 'p', allowHtml: true},
+            {tag: 'form', onsubmit: 'generateRecoveryLink', components: [
+                {kind: 'onyx.InputDecorator', classes: "recovery", components: [
+                    {kind: 'onyx.Input', name: "recoveryVerifier"}
+                ]},
+                {kind: 'onyx.Button', content: "Generate", classes: "recovery", onclick: "generateRecoveryLink"}
+            ]},
+            {tag: 'p', name: 'recoveryLinkOutput', classes: 'recovery'}
+        ]},
+        {name: 'pleaseLogIn', content: 'Please log in above to use the Account Center.'}
+    ],
     create: function() {
         this.inherited(arguments);
         this.bubble('onSetTitle', {section: 'Account Center'});
+        this.loginStatusChange();
     },
     generateRecoveryLink: function(inSender, inEvent) {
         if (this.$.recoveryVerifier.getValue() != 'blërg') {
@@ -49,5 +57,9 @@ enyo.kind({
         });
 
         req.go();
+    },
+    loginStatusChange: function(inSender, inEvent) {
+        this.$.pleaseLogIn.setShowing(!blerg.API.loggedIn);
+        this.$.accountCenterContent.setShowing(blerg.API.loggedIn);
     }
 });
index 6e651fc..940b8e6 100644 (file)
@@ -1,5 +1,8 @@
 enyo.kind({
     name: 'blerg.EmailForm',
+    handlers: {
+        onLogin: "loginStatusChange"
+    },
     components: [
         {name: 'emailRegisterForm', components: [
             {content: "Register an email address to get daily digest updates of your feed. We can also use this address to send you a password recovery link if you forget your password.", tag: 'p'},
@@ -91,5 +94,8 @@ enyo.kind({
         });
 
         req.go();
+    },
+    loginStatusChange: function(inSender, inEvent) {
+        this.fetchEmailStatus();
     }
 });