|
|
|
@ -8,7 +8,7 @@ export default class extends Controller { |
|
|
|
async loginAct() { |
|
|
|
async loginAct() { |
|
|
|
const tags = [ |
|
|
|
const tags = [ |
|
|
|
['u', window.location.origin + '/login'], |
|
|
|
['u', window.location.origin + '/login'], |
|
|
|
['method', 'GET'] |
|
|
|
['method', 'POST'] |
|
|
|
] |
|
|
|
] |
|
|
|
const ev = { |
|
|
|
const ev = { |
|
|
|
created_at: Math.floor(Date.now()/1000), |
|
|
|
created_at: Math.floor(Date.now()/1000), |
|
|
|
@ -20,15 +20,14 @@ export default class extends Controller { |
|
|
|
const signed = await window.nostr.signEvent(ev); |
|
|
|
const signed = await window.nostr.signEvent(ev); |
|
|
|
// base64 encode and send as Auth header
|
|
|
|
// base64 encode and send as Auth header
|
|
|
|
const result = await fetch('/login', { |
|
|
|
const result = await fetch('/login', { |
|
|
|
method: 'GET', |
|
|
|
method: 'POST', |
|
|
|
|
|
|
|
credentials: 'same-origin', |
|
|
|
headers: { |
|
|
|
headers: { |
|
|
|
'Authorization': 'Nostr ' + btoa(JSON.stringify(signed)) |
|
|
|
'Authorization': 'Nostr ' + btoa(JSON.stringify(signed)) |
|
|
|
} |
|
|
|
} |
|
|
|
}).then(response => { |
|
|
|
}).then(response => { |
|
|
|
if (response.ok) return response.json(); |
|
|
|
if (!response.ok) return false; |
|
|
|
return false; |
|
|
|
return 'Authentication Successful'; |
|
|
|
}).then(res => { |
|
|
|
|
|
|
|
return res; |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
if (!!result) { |
|
|
|
if (!!result) { |
|
|
|
this.component.render(); |
|
|
|
this.component.render(); |
|
|
|
|