-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
124 additions
and
19 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
63 changes: 63 additions & 0 deletions
63
lib/bookmark_web/templates/user_registration/new_with_nostr.html.heex
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 @@ | ||
<div class="display-box"> | ||
<h1 class="display-box-headline" style="color: white;">Create an account</h1> | ||
|
||
<.form :let={f} for={@changeset} action={Routes.user_registration_path(@conn, :create)} OnSubmit="doNip07Login()"> | ||
<%= if @changeset.action do %> | ||
<div class="alert alert-danger"> | ||
<p>Oops, something went wrong! Please check the errors below.</p> | ||
</div> | ||
<% end %> | ||
<span style="color: #1e1e1e"> | ||
|
||
<%= label(:username, "Username", style: "color:white;") %> | ||
<%= text_input(f, :username, id: :username, required: true, class: "form-input", placeholder: "Choose your username") %> | ||
<%= error_tag(f, :username) %> | ||
|
||
<%= text_input(f, :nostr_key, id: :nostr_key, value: "", hidden: true) %> | ||
|
||
<%= text_input(f, :register_type, value: "nostr", hidden: true) %> | ||
|
||
</span> | ||
<div> | ||
<br> | ||
<%= submit("Register", class: "donate-button") %> | ||
</div> | ||
</.form> | ||
|
||
<p> | ||
<%= link("Log in", to: Routes.user_session_path(@conn, :new)) %> | <%= link( | ||
"Forgot your password?", | ||
to: Routes.user_reset_password_path(@conn, :new) | ||
) %> | ||
</p> | ||
</div> | ||
|
||
|
||
<script> | ||
let nip07LoginExecuted = false; | ||
async function doNip07Login() { | ||
if (nip07LoginExecuted) { return; } | ||
event.preventDefault(); | ||
var username = document.getElementById('username'); | ||
if (username.value != "") { | ||
const pubKey = await unwrap(window.nostr).getPublicKey(); | ||
const nostrKeyInput = document.getElementById('nostr_key'); | ||
nostrKeyInput.value = pubKey; | ||
nip07LoginExecuted = true; | ||
const form = document.querySelector('form'); | ||
form.submit(); | ||
} | ||
} | ||
function unwrap(v) { | ||
if (v === undefined || v === null) { | ||
throw new Error("missing value"); | ||
} | ||
return v; | ||
} | ||
</script> |