Skip to content

Commit

Permalink
Merge pull request #18 from nosdav/login
Browse files Browse the repository at this point in the history
login
  • Loading branch information
melvincarvalho authored May 11, 2024
2 parents aab5274 + 771df7d commit 3f1e1e1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
Empty file added .service
Empty file.
33 changes: 30 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,36 @@ export class App extends Component {
}

userLogin = async () => {
const userPublicKey = await window.nostr.getPublicKey()
console.log(`Logged in with public key: ${userPublicKey}`)
await this.setState({ userPublicKey: userPublicKey })
var userPublicKey
try {
userPublicKey = await window.nostr.getPublicKey();
if (userPublicKey) {
Swal.fire({
title: "Logged in!",
text: "Logged in with public key!",
icon: "success"
});
} else {
Swal.fire({
icon: "error",
title: "Oops...",
text: "Something went wrong!",
footer: '<p><a target="_blank" href="https://nostrapps.github.io/extensions/">Please install a nostr extension</a></p>'

});
}
} catch (error) {
Swal.fire({
icon: "error",
title: "Oops...",
text: "Something went wrong!",
footer: '<p><a target="_blank" href="https://nostrapps.github.io/extensions/">Please install a nostr extension</a></p>'
});
console.error('Login error:', error);
}

console.log(`Logged in with public key: ${userPublicKey}`);
await this.setState({ userPublicKey: userPublicKey });
this.loadFile()
}

Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="css/style.css" />
<title>NosDAV Pastebin</title>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script type="application/ld+json" id="data">
{
"@id": "#app",
Expand Down

0 comments on commit 3f1e1e1

Please sign in to comment.