API key support

This commit is contained in:
Kyle Drake 2017-05-13 18:18:34 -05:00
parent 73ec613283
commit 1274e9fa63
8 changed files with 93 additions and 17 deletions

View file

@ -29,6 +29,8 @@
<li><a href="#username" data-toggle="tab">Change Site (User) Name</a></li>
<li><a href="#tipping" data-toggle="tab">Tipping</a></li>
<li><a href="#api_key" data-toggle="tab">API Key</a></li>
<% if @site.admin_nsfw != true %>
<li><a href="#nsfw" data-toggle="tab">18+</a></li>
<% end %>
@ -53,7 +55,9 @@
<div class="tab-pane" id="tipping">
<%== erb :'settings/site/tipping' %>
</div>
<div class="tab-pane" id="api_key">
<%== erb :'settings/site/api_key' %>
</div>
<% if @site.admin_nsfw != true %>
<div class="tab-pane" id="nsfw">
<%== erb :'settings/site/nsfw' %>

View file

@ -0,0 +1,4 @@
<form method="POST" action="/settings/<%= @site.username %>/generate_api_key">
<%== csrf_token_input_html %>
<input class="btn-Action" type="submit" value="Generate API Key">
</form>

View file

@ -0,0 +1,19 @@
<h2>API Key</h2>
<p>
An API Key can be used with the <a href="https://neocities.org/api">Neocities API</a> to allow for changes to your site without requiring login credentials. <strong>This API key allows full write access to your site. Keep it secret, keep it safe.</strong>
</p>
<% if @site.api_key %>
<p>Your API key:<br><strong><%= @site.api_key %></strong></p>
<p>
If you need to regenerate the key for some reason, you can do that below.
Keep in mind that this will make the old key no longer function.
</p>
<%== erb :'settings/site/_api_key_form', layout: false %>
<% else %>
<p>You haven't yet generated an API key, click the button to create one:</p>
<%== erb :'settings/site/_api_key_form', layout: false %>
<% end %>