浏览代码

Added API token information

Will Browning 5 年之前
父节点
当前提交
9ad4588d0c
共有 2 个文件被更改,包括 51 次插入9 次删除
  1. 40 8
      resources/js/components/ApiToken.vue
  2. 11 1
      resources/views/settings/show.blade.php

+ 40 - 8
resources/js/components/ApiToken.vue

@@ -1,5 +1,5 @@
 <template>
 <template>
-  <div>
+  <div class="mt-6">
     <h3 class="font-bold text-xl">{{ token ? 'Rotate' : 'Generate' }} API Token</h3>
     <h3 class="font-bold text-xl">{{ token ? 'Rotate' : 'Generate' }} API Token</h3>
 
 
     <div class="my-4 w-24 border-b-2 border-grey-200"></div>
     <div class="my-4 w-24 border-b-2 border-grey-200"></div>
@@ -17,7 +17,7 @@
       :class="loading ? 'cursor-not-allowed' : ''"
       :class="loading ? 'cursor-not-allowed' : ''"
       :disabled="loading"
       :disabled="loading"
     >
     >
-      {{ token ? 'Rotate' : 'Generate' }} Token
+      {{ token ? 'Rotate' : 'Generate New' }} Token
       <loader v-if="loading" />
       <loader v-if="loading" />
     </button>
     </button>
 
 
@@ -32,12 +32,7 @@
         To revoke the current API token simply click the button below.
         To revoke the current API token simply click the button below.
       </p>
       </p>
 
 
-      <button
-        @click="revoke"
-        class="text-red-500 font-bold focus:outline-none"
-        :class="revokeLoading ? 'cursor-not-allowed' : ''"
-        :disabled="revokeLoading"
-      >
+      <button @click="revokeModalOpen = true" class="text-red-500 font-bold focus:outline-none">
         Revoke Token
         Revoke Token
       </button>
       </button>
     </div>
     </div>
@@ -75,6 +70,37 @@
         </div>
         </div>
       </div>
       </div>
     </Modal>
     </Modal>
+
+    <Modal :open="revokeModalOpen" @close="closeRevokeModal">
+      <div class="max-w-lg w-full bg-white rounded-lg shadow-2xl px-6 py-6">
+        <h2
+          class="font-semibold text-grey-900 text-2xl leading-tight border-b-2 border-grey-100 pb-4"
+        >
+          Revoke API Token
+        </h2>
+        <p class="my-4 text-grey-700">
+          Any browser extension, application or script using this API token will no longer be able
+          to access the AnonAddy API. This action cannot be undone.
+        </p>
+        <div class="mt-6">
+          <button
+            @click="revoke"
+            class="bg-red-500 hover:bg-red-600 text-white font-bold py-3 px-4 rounded focus:outline-none"
+            :class="revokeLoading ? 'cursor-not-allowed' : ''"
+            :disabled="revokeLoading"
+          >
+            Revoke Token
+            <loader v-if="revokeLoading" />
+          </button>
+          <button
+            @click="closeRevokeModal"
+            class="ml-4 px-4 py-3 text-grey-800 font-semibold bg-white hover:bg-grey-50 border border-grey-100 rounded focus:outline-none"
+          >
+            Close
+          </button>
+        </div>
+      </div>
+    </Modal>
   </div>
   </div>
 </template>
 </template>
 
 
@@ -96,6 +122,7 @@ export default {
       loading: false,
       loading: false,
       revokeLoading: false,
       revokeLoading: false,
       modalOpen: false,
       modalOpen: false,
+      revokeModalOpen: false,
       token: this.initialToken,
       token: this.initialToken,
     }
     }
   },
   },
@@ -125,11 +152,13 @@ export default {
           headers: { 'Content-Type': 'application/json' },
           headers: { 'Content-Type': 'application/json' },
         })
         })
         .then(response => {
         .then(response => {
+          this.revokeModalOpen = false
           this.revokeLoading = false
           this.revokeLoading = false
           this.token = ''
           this.token = ''
           this.success('Token Revoked Successfully!')
           this.success('Token Revoked Successfully!')
         })
         })
         .catch(error => {
         .catch(error => {
+          this.revokeModalOpen = false
           this.revokeLoading = false
           this.revokeLoading = false
           this.error()
           this.error()
         })
         })
@@ -137,6 +166,9 @@ export default {
     closeModal() {
     closeModal() {
       this.modalOpen = false
       this.modalOpen = false
     },
     },
+    closeRevokeModal() {
+      this.revokeModalOpen = false
+    },
     clipboardSuccess() {
     clipboardSuccess() {
       this.success('Copied to clipboard')
       this.success('Copied to clipboard')
     },
     },

+ 11 - 1
resources/views/settings/show.blade.php

@@ -432,11 +432,21 @@
             <h2 class="text-3xl font-bold">
             <h2 class="text-3xl font-bold">
                 API
                 API
             </h2>
             </h2>
-            <p class="text-grey-500">Manage your API Token (the API is currently a work in progress)</p>
+            <p class="text-grey-500">Manage your API Token</p>
         </div>
         </div>
 
 
         <div class="px-6 py-8 md:p-10 bg-white rounded-lg shadow mb-10">
         <div class="px-6 py-8 md:p-10 bg-white rounded-lg shadow mb-10">
 
 
+            <h3 class="font-bold text-xl">
+                Information
+            </h3>
+
+            <div class="mt-4 w-24 border-b-2 border-grey-200"></div>
+
+            <p class="mt-6">
+                Your API token can be used with the <a href="https://github.com/anonaddy/browser-extension" target="_blank" rel="nofollow noopener noreferrer" class="text-indigo-700">open-source</a> AnonAddy browser extension on <a href="https://addons.mozilla.org/en-GB/firefox/addon/anonaddy/" target="_blank" rel="nofollow noopener noreferrer" class="text-indigo-700">Firefox</a> or <a href="https://chrome.google.com/webstore/detail/anonaddy/iadbdpnoknmbdeolbapdackdcogdmjpe" target="_blank" rel="nofollow noopener noreferrer" class="text-indigo-700">Chrome / Brave</a> to generate UUID aliases. Simply paste the token generated below into the browser extension to get started. Your API token is secret and should be treated like your password.
+            </p>
+
             <api-token initial-token="{{ $user->api_token }}" />
             <api-token initial-token="{{ $user->api_token }}" />
 
 
         </div>
         </div>