-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from MaddyGuthridge/maddy-password-change-ui
Implement UI for changing auth information
- Loading branch information
Showing
8 changed files
with
269 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<script lang="ts"> | ||
import api from "$endpoints"; | ||
export let username: string; | ||
let originalPassword = ""; | ||
let newPassword = ""; | ||
let repeatNewPassword = ""; | ||
async function submitChangePassword() { | ||
await api().admin.auth.change(username, originalPassword, newPassword); | ||
originalPassword = ""; | ||
newPassword = ""; | ||
repeatNewPassword = ""; | ||
} | ||
</script> | ||
|
||
<div> | ||
<h2>Change authentication</h2> | ||
<form on:submit={submitChangePassword}> | ||
<p> | ||
Username | ||
<br /> | ||
<input placeholder="Your account username" bind:value={username} /> | ||
</p> | ||
<p> | ||
Original password | ||
<br /> | ||
<input | ||
type="password" | ||
placeholder="Your original password" | ||
bind:value={originalPassword} | ||
/> | ||
</p> | ||
<p> | ||
New password | ||
<br /> | ||
<input | ||
type="password" | ||
placeholder="A unique and secure password" | ||
bind:value={newPassword} | ||
/> | ||
</p> | ||
<p> | ||
Repeat new password | ||
<br /> | ||
<input | ||
type="password" | ||
placeholder="Your new password again" | ||
bind:value={repeatNewPassword} | ||
/> | ||
</p> | ||
{#if newPassword != repeatNewPassword} | ||
<p>New passwords much match</p> | ||
{/if} | ||
<p> | ||
<input | ||
type="submit" | ||
value="Change password" | ||
disabled={newPassword != repeatNewPassword} | ||
/> | ||
</p> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<script lang="ts"> | ||
import api from "$endpoints"; | ||
export let data: import("./$types").PageData; | ||
// Git setup | ||
let gitUrl = ""; | ||
async function submitSwitchToGit() { | ||
await api().admin.git.init(gitUrl); | ||
} | ||
// Git controls | ||
let commitMessage = ""; | ||
async function gitCommit() { | ||
await api().admin.git.commit(commitMessage); | ||
} | ||
</script> | ||
|
||
<div> | ||
{#if data.repo} | ||
<h2>Git status</h2> | ||
<p>Current branch: {data.repo.branch}</p> | ||
<p>Current commit: {data.repo.commit}</p> | ||
<p> | ||
{#if data.repo.behind} | ||
{data.repo.behind} commits behind. | ||
{/if} | ||
{#if data.repo.ahead} | ||
{data.repo.ahead} commits ahead. | ||
{/if} | ||
</p> | ||
|
||
<!-- Push/pull --> | ||
{#if data.repo.behind} | ||
<button on:click={() => api().admin.git.push()}>Push</button> | ||
{:else if data.repo.ahead} | ||
<button on:click={() => api().admin.git.pull()}>Pull</button> | ||
{/if} | ||
|
||
<!-- Commit --> | ||
{#if data.repo.clean} | ||
<h3>Changes</h3> | ||
Working tree clean. | ||
{:else} | ||
<h3>Changes</h3> | ||
|
||
<ul> | ||
{#each data.repo.changes as change} | ||
{#if change.from} | ||
<li>Rename {change.from} to ({change.path})</li> | ||
{:else if change.index === "?"} | ||
<li>Create {change.path}</li> | ||
{:else if change.index === "D"} | ||
<li>Delete {change.path}</li> | ||
{:else} | ||
<li>Update {change.path}</li> | ||
{/if} | ||
{/each} | ||
</ul> | ||
|
||
<form on:submit|preventDefault={gitCommit}> | ||
<input | ||
required | ||
type="text" | ||
name="commit-message" | ||
id="commit-message" | ||
placeholder="Commit message" | ||
bind:value={commitMessage} | ||
/> | ||
<input type="submit" value="Commit changes" /> | ||
</form> | ||
{/if} | ||
{:else} | ||
<h2>Git is currently not in use</h2> | ||
|
||
You can use a Git repository to back up your portfolio data. Enter the clone | ||
URL for an empty Git repository and it will be set up for you. | ||
|
||
<form on:submit|preventDefault={submitSwitchToGit}> | ||
<input | ||
required | ||
type="text" | ||
name="git-url" | ||
id="git-url" | ||
placeholder="git@github.com:MaddyGuthridge/Minifolio.git" | ||
bind:value={gitUrl} | ||
/> | ||
<input type="submit" value="Switch to a Git repository" /> | ||
</form> | ||
{/if} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<script lang="ts"> | ||
import { goto } from "$app/navigation"; | ||
import api from "$endpoints"; | ||
async function logOut() { | ||
await api().admin.auth.revoke(); | ||
goto("/admin/login"); | ||
} | ||
</script> | ||
|
||
<div> | ||
<h2>Log out of all sessions</h2> | ||
<p>This will sign you out on all of your devices (including this one).</p> | ||
<button on:click={logOut}>Log out of all sessions</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script> | ||
import api from "$endpoints"; | ||
</script> | ||
|
||
<div> | ||
<h2>Reload data from disk</h2> | ||
If you have edited your data manually, you can use this button to refresh it. | ||
<button on:click={() => api().admin.data.refresh()}>Refresh data</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.