165 lines
6.8 KiB
ERB
165 lines
6.8 KiB
ERB
<div class="page-head">
|
|
<div>
|
|
<h1>Settings</h1>
|
|
<p class="lede">Manage your account and users</p>
|
|
</div>
|
|
</div>
|
|
|
|
<% if @notice %>
|
|
<div class="alert alert-success">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
|
|
<div><%= h(@notice) %></div>
|
|
</div>
|
|
<% end %>
|
|
<% if @error %>
|
|
<div class="alert alert-error">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
|
|
<div><%= h(@error) %></div>
|
|
</div>
|
|
<% end %>
|
|
|
|
<div class="surface">
|
|
<div class="surface-head">
|
|
<div>
|
|
<h2>Your account</h2>
|
|
<p class="lede">Signed in as <strong style="color: var(--fg);"><%= h(current_user) %></strong> · <%= h(current_role) %></p>
|
|
</div>
|
|
</div>
|
|
|
|
<form method="post" action="<%= to("/admin/settings/password") %>">
|
|
<input type="hidden" name="_csrf" value="<%= csrf_token %>">
|
|
<h3 style="margin: 0 0 0.75rem;">Change password</h3>
|
|
<div class="field-row">
|
|
<div class="field">
|
|
<label for="current_password">Current password</label>
|
|
<input id="current_password" class="input" type="password" name="current_password" autocomplete="current-password">
|
|
</div>
|
|
<div class="field">
|
|
<label for="new_password">New password</label>
|
|
<input id="new_password" class="input" type="password" name="new_password" autocomplete="new-password">
|
|
</div>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Update password</button>
|
|
</form>
|
|
|
|
<div style="border-top: 1px solid var(--border); margin: 1.5rem 0;"></div>
|
|
|
|
<form method="post" action="<%= to("/admin/settings/name") %>">
|
|
<input type="hidden" name="_csrf" value="<%= csrf_token %>">
|
|
<h3 style="margin: 0 0 0.75rem;">Display name</h3>
|
|
<div class="field">
|
|
<label for="name">Real name</label>
|
|
<input id="name" class="input" type="text" name="name" value="<%= h(current_user_record&.name) %>" placeholder="Your real name" style="max-width: 360px;">
|
|
<p class="help">Used to pre-fill the author field for new posts. Leave empty to use your username.</p>
|
|
</div>
|
|
<button type="submit" class="btn">Save name</button>
|
|
</form>
|
|
|
|
<div style="border-top: 1px solid var(--border); margin: 1.5rem 0;"></div>
|
|
|
|
<form method="post" action="<%= to("/admin/settings/fediverse") %>">
|
|
<input type="hidden" name="_csrf" value="<%= csrf_token %>">
|
|
<h3 style="margin: 0 0 0.75rem;">Fediverse handle</h3>
|
|
<div class="field">
|
|
<label for="fediverse_creator">Fediverse creator</label>
|
|
<input id="fediverse_creator" class="input" type="text" name="fediverse_creator"
|
|
value="<%= h(current_user_record&.fediverse_creator) %>"
|
|
placeholder="@user@instance.tld" style="max-width: 360px;">
|
|
<p class="help">Used to pre-fill the Fediverse creator for new posts.</p>
|
|
</div>
|
|
<button type="submit" class="btn">Save handle</button>
|
|
</form>
|
|
|
|
<div style="border-top: 1px solid var(--border); margin: 1.5rem 0;"></div>
|
|
|
|
<form method="post" action="<%= to("/admin/settings/username") %>">
|
|
<input type="hidden" name="_csrf" value="<%= csrf_token %>">
|
|
<h3 style="margin: 0 0 0.75rem;">Change username</h3>
|
|
<div class="field">
|
|
<label for="username">New username</label>
|
|
<input id="username" class="input" type="text" name="username" value="<%= h(current_user) %>" style="max-width: 360px;">
|
|
</div>
|
|
<button type="submit" class="btn">Update username</button>
|
|
</form>
|
|
</div>
|
|
|
|
<% if admin? %>
|
|
<div class="surface">
|
|
<div class="surface-head">
|
|
<div>
|
|
<h2>Users</h2>
|
|
<p class="lede">Add or remove admin and editor accounts</p>
|
|
</div>
|
|
</div>
|
|
|
|
<table class="data-table">
|
|
<thead>
|
|
<tr><th>Username</th><th>Role</th><th></th></tr>
|
|
</thead>
|
|
<tbody>
|
|
<% @users.each do |user| %>
|
|
<tr>
|
|
<td>
|
|
<strong><%= h(user.username) %></strong>
|
|
<% if user.username == current_user %><span class="badge badge-accent" style="margin-left: 0.4rem;">you</span><% end %>
|
|
</td>
|
|
<td>
|
|
<% if user.username == current_user %>
|
|
<span class="badge badge-neutral"><%= h(user.role) %></span>
|
|
<% else %>
|
|
<form method="post"
|
|
action="<%= h(to("/admin/settings/users/#{user.username}/role")) %>"
|
|
style="margin: 0;">
|
|
<input type="hidden" name="_csrf" value="<%= csrf_token %>">
|
|
<select class="select" name="role" onchange="this.form.submit()" style="width: 130px; padding: 0.35rem 0.6rem; font-size: 0.82rem;">
|
|
<% Volumen::Users::ROLES.each do |role| %>
|
|
<option value="<%= role %>" <%= user.role == role ? "selected" : "" %>><%= role %></option>
|
|
<% end %>
|
|
</select>
|
|
</form>
|
|
<% end %>
|
|
</td>
|
|
<td>
|
|
<% unless user.username == current_user %>
|
|
<form method="post"
|
|
action="<%= h(to("/admin/settings/users/#{user.username}/delete")) %>"
|
|
onsubmit="return confirm('Remove this user?');"
|
|
style="margin: 0;">
|
|
<input type="hidden" name="_csrf" value="<%= csrf_token %>">
|
|
<button type="submit" class="btn btn-sm btn-danger">Remove</button>
|
|
</form>
|
|
<% end %>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
|
|
<div style="border-top: 1px solid var(--border); margin: 1.5rem 0;"></div>
|
|
|
|
<form method="post" action="<%= to("/admin/settings/users") %>">
|
|
<input type="hidden" name="_csrf" value="<%= csrf_token %>">
|
|
<h3 style="margin: 0 0 0.75rem;">Add user</h3>
|
|
<div class="field-row-3">
|
|
<div class="field">
|
|
<label for="new-username">Username</label>
|
|
<input id="new-username" class="input" type="text" name="username">
|
|
</div>
|
|
<div class="field">
|
|
<label for="new-password">Password</label>
|
|
<input id="new-password" class="input" type="password" name="password" autocomplete="new-password">
|
|
</div>
|
|
<div class="field">
|
|
<label for="new-role">Role</label>
|
|
<select id="new-role" class="select" name="role">
|
|
<% Volumen::Users::ROLES.each do |role| %>
|
|
<option value="<%= role %>" <%= role == Volumen::Users::DEFAULT_ROLE ? "selected" : "" %>><%= role %></option>
|
|
<% end %>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Add user</button>
|
|
</form>
|
|
</div>
|
|
<% end %>
|