Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: manage user API tokens #6

Merged
merged 17 commits into from
May 8, 2024
9 changes: 8 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Server env
POSTGRES_USER="postgres"
POSTGRES_PASSWORD="localpw"
POSTGRES_URI="localhost"
POSTGRES_PORT="5432"
POSTGRES_DB_NAME="forc_pub"
POSTGRES_DB_NAME="forc_pub"

# Local env
CORS_HTTP_ORIGIN="http://localhost:3000"

# Diesel CLI env
DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_URI}/${POSTGRES_DB_NAME}"
59 changes: 57 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ diesel = { version = "2.1.6", features = ["postgres", "uuid", "r2d2"] }
dotenvy = "0.15"
uuid = "1.8.0"
diesel_migrations = "2.1.0"
rand = "0.8.5"
sha2 = "0.10.8"
serial_test = "3.1.1"
109 changes: 105 additions & 4 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
"@types/node": "^16.18.91",
"@types/react": "^18.2.67",
"@types/react-dom": "^18.2.22",
"axios": "^1.6.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.22.3",
"react-scripts": "5.0.1",
"react-use-cookie": "^1.5.0",
"typed-axios-instance": "^3.3.1",
"typescript": "^4.9.5",
"usehooks-ts": "^3.0.2",
"web-vitals": "^2.1.4"
Expand Down
43 changes: 43 additions & 0 deletions app/src/features/tokens/components/CopyableToken.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react';
import IconButton from '@mui/material/IconButton';
import ContentCopyIcon from '@mui/icons-material/ContentCopy';

export interface CopyableProps {
token: string;
}

async function handleCopy(value: string) {
await navigator.clipboard.writeText(value);
}

function CopyableToken({ token }: CopyableProps) {
return (
<div
style={{
display: 'flex',
flexDirection: 'row',
fontSize: '16px',
background: '#383838',
color: 'white',
borderRadius: '4px',
textAlign: 'left',
position: 'relative',
}}>
<div
style={{
flex: '1 1 auto',
overflow: 'auto',
padding: '0 1rem',
}}>
<pre>{token}</pre>
</div>
<div style={{ flex: '0 0 auto', margin: '5px 5px 0 0' }}>
<IconButton onClick={() => handleCopy(token)} aria-label='copy'>
<ContentCopyIcon style={{ color: 'white' }} />
</IconButton>
</div>
</div>
);
}

export default CopyableToken;
Loading
Loading