Compare commits

...

2 Commits

Author SHA1 Message Date
b
ed29d779b4 Merge pull request 'fix: robohash image missing with NIP05 login' (#50) from robohash into main
All checks were successful
Release / build_and_release (push) Successful in 1m8s
Reviewed-on: https://git.sigit.io/sig/it/pulls/50
2024-05-16 15:51:23 +00:00
Davinci
9baf0ecaba fix: robohash image missing with NIP05 login 2024-05-16 17:15:21 +02:00

View File

@ -32,20 +32,44 @@ export class AuthController {
* or error if otherwise
*/
async authenticateAndFindMetadata(pubkey: string) {
this.metadataController
.findMetadata(pubkey)
.then((event) => {
store.dispatch(setMetadataEvent(event))
})
.catch((err) => {
console.warn('Error occurred while finding metadata', err)
const emptyMetadata = this.metadataController.getEmptyMetadataEvent()
emptyMetadata.content = JSON.stringify({
picture: getRoboHashPicture(pubkey)
})
this.metadataController
.findMetadata(pubkey)
.then((event) => {
if (event) {
// In case of NIP05 there is scenario where login content will be populated but without an image
// In such case we will add robohash image
if (event.content) {
const content = JSON.parse(event.content)
if (!content) {
event.content = ''
}
if (!content.picture) {
content.picture = getRoboHashPicture(pubkey)
}
event.content = JSON.stringify(content)
} else {
event.content = JSON.stringify({
picture: getRoboHashPicture(pubkey)
})
}
store.dispatch(setMetadataEvent(event))
} else {
store.dispatch(setMetadataEvent(emptyMetadata))
}
})
.catch((err) => {
console.warn('Error occurred while finding metadata', err)
store.dispatch(setMetadataEvent(emptyMetadata))
})