mirror of
https://github.com/RoboSats/robosats.git
synced 2025-07-19 17:23:19 +00:00
Merge pull request #2077 from RoboSats/keep-nostr-updated
Keep nostr updated
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import React, { useContext, useState } from 'react';
|
import React, { useContext, useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
AppBar as Bar,
|
AppBar as Bar,
|
||||||
Toolbar,
|
Toolbar,
|
||||||
@ -65,6 +65,10 @@ const AppBar = ({ changePage }: AppBarProps): React.JSX.Element => {
|
|||||||
void garage.createRobot(federation, token, Object.keys(garage.slots).length > 0);
|
void garage.createRobot(federation, token, Object.keys(garage.slots).length > 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!show) setOpenGarage(false);
|
||||||
|
}, [show]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ flexGrow: 1 }}>
|
<Box sx={{ flexGrow: 1 }}>
|
||||||
<Bar position='fixed' sx={{ top: 'auto', bottom: 0 }}>
|
<Bar position='fixed' sx={{ top: 'auto', bottom: 0 }}>
|
||||||
|
@ -90,14 +90,15 @@ class RobotTokenSHA256AuthenticationMiddleWare:
|
|||||||
if token.user.last_login < timezone.now() - timedelta(minutes=2):
|
if token.user.last_login < timezone.now() - timedelta(minutes=2):
|
||||||
update_last_login(None, token.user)
|
update_last_login(None, token.user)
|
||||||
|
|
||||||
# START deprecate after v0.6.0
|
# START deprecate after v0.8.0
|
||||||
# Add the hash_id to robots created before hash_ids were introduced
|
# Add the nostr_pubkey to robots created before nostr_pubkey were introduced
|
||||||
if not token.user.robot.hash_id:
|
nostr_pubkey = request.META.get("NOSTR_PUBKEY", "").replace(
|
||||||
token_sha256 = base91_to_hex(token_sha256_b91)
|
"Nostr ", ""
|
||||||
hash = hashlib.sha256(token_sha256.encode("utf-8")).hexdigest()
|
)
|
||||||
token.user.robot.hash_id = hash
|
token.user.robot.nostr_pubkey = nostr_pubkey
|
||||||
token.user.robot.save(update_fields=["hash_id"])
|
|
||||||
# END deprecate after v0.6.0
|
token.user.robot.save(update_fields=["nostr_pubkey"])
|
||||||
|
# END deprecate after v0.8.0
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
update_last_login(None, token.user)
|
update_last_login(None, token.user)
|
||||||
|
Reference in New Issue
Block a user