Delete and reload cookies on avatar login

This commit is contained in:
Reckless_Satoshi 2022-06-20 07:26:19 -07:00
parent 009c88a988
commit 7eb29fb57e
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
4 changed files with 24 additions and 9 deletions

View File

@ -122,6 +122,10 @@ class BottomBar extends Component {
return url.split('/')[2]
}
showProfileButton = () =>{
return (this.props.avatarLoaded && (this.props.token ? getCookie('robot_token')==this.props.token : true ) && (getCookie('sessionid')))
}
bottomBarDesktop =()=>{
const { t } = this.props;
var hasRewards = this.state.earned_rewards > 0 ? true: false;
@ -132,7 +136,7 @@ bottomBarDesktop =()=>{
<Grid container>
<Grid item xs={1.9}>
<div style={{display: this.props.avatarLoaded && (this.props.token ? getCookie('robot_token')==this.props.token : true ) ? '':'none'}}>
<div style={{display: this.showProfileButton() ? '':'none'}}>
<ListItemButton onClick={this.handleClickOpenProfile} >
<Tooltip
open={hasRewards || hasOrder}
@ -161,7 +165,7 @@ bottomBarDesktop =()=>{
<ListItemIcon size="small">
<IconButton
color="primary"
onClick={()=> this.props.setAppState({buyChecked: false, sellChecked: true, type:0}) && this.getInfo()}
onClick={()=> this.props.setAppState({buyChecked: false, sellChecked: true, type:0}) & this.getInfo()}
to={`/book/`}
component={LinkRouter} >
<InventoryIcon/>
@ -180,7 +184,7 @@ bottomBarDesktop =()=>{
<ListItemIcon size="small">
<IconButton
color="primary"
onClick={()=> this.props.setAppState({buyChecked: true, sellChecked: false, type:1}) && this.getInfo()}
onClick={()=> this.props.setAppState({buyChecked: true, sellChecked: false, type:1}) & this.getInfo()}
to={`/book/`}
component={LinkRouter} >
<SellIcon/>
@ -323,7 +327,7 @@ bottomBarPhone =()=>{
<Grid container>
<Grid item xs={1.6}>
<div style={{display: this.props.avatarLoaded && (this.props.token ? getCookie('robot_token')==this.props.token : true ) ? '':'none'}}>
<div style={{display: this.showProfileButton() ? '':'none'}}>
<Tooltip open={hasRewards || hasOrder}
title={(hasRewards ? t("You can claim satoshis!")+" ": "" )+
(hasOrder ? t("You have an active order"):"")}>
@ -347,7 +351,7 @@ bottomBarPhone =()=>{
<Tooltip enterTouchDelay={300} title={t("Number of public BUY orders")}>
<IconButton
color="primary"
onClick={()=> this.props.setAppState({buyChecked: false, sellChecked: true, type:0}) && this.getInfo()}
onClick={()=> this.props.setAppState({buyChecked: false, sellChecked: true, type:0}) & this.getInfo()}
to={`/book/`}
component={LinkRouter} >
<Badge badgeContent={this.state.num_public_buy_orders} color="action">
@ -361,7 +365,7 @@ bottomBarPhone =()=>{
<Tooltip enterTouchDelay={300} title={t("Number of public SELL orders")}>
<IconButton
color="primary"
onClick={()=> this.props.setAppState({buyChecked: true, sellChecked: false, type:1}) && this.getInfo()}
onClick={()=> this.props.setAppState({buyChecked: true, sellChecked: false, type:1}) & this.getInfo()}
to={`/book/`}
component={LinkRouter} >
<Badge badgeContent={this.state.num_public_sell_orders} color="action">
@ -418,7 +422,6 @@ bottomBarPhone =()=>{
</IconButton>
</Tooltip>
</Grid>
</Grid>
</Grid>
</Paper>

View File

@ -15,7 +15,7 @@ import { RoboSatsNoTextIcon } from "./Icons";
import { sha256 } from 'js-sha256';
import { genBase62Token, tokenStrength } from "../utils/token";
import { genKey } from "../utils/pgp";
import { getCookie, writeCookie } from "../utils/cookies";
import { getCookie, writeCookie, deleteCookie } from "../utils/cookies";
import { saveAsJson } from "../utils/saveFile";
@ -115,6 +115,11 @@ class UserGenPage extends Component {
};
fetch("/api/user", requestOptions)
.then((response) => response.json());
deleteCookie("sessionid");
deleteCookie("robot_token");
deleteCookie("pub_key");
deleteCookie("enc_priv_key");
}
handleClickNewRandomToken=()=>{

View File

@ -15,5 +15,9 @@ export const getCookie = (name) => {
};
export const writeCookie = (key,value) => {
document.cookie=key+"="+value;
document.cookie=`${key}=${value};path=/`;
}
export const deleteCookie = (name) => {
document.cookie = `${name}= ; expires = Thu, 01 Jan 1970 00:00:00 GMT`
}

View File

@ -43,6 +43,9 @@ ALLOWED_HOSTS = [
"127.0.0.1",
]
# Allows Session Cookie to be read by Javascript on Client side.
SESSION_COOKIE_HTTPONLY = False
# Application definition
INSTALLED_APPS = [