Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Add access token to personal section

Jakub Novak0153624f10d8
diff --git a/apps/docs/src/app/(dashboard)/dashboard/page.tsx b/apps/docs/src/app/(dashboard)/dashboard/page.tsx
index 80bfaee29..fa311cb8e 100644
--- a/apps/docs/src/app/(dashboard)/dashboard/page.tsx
+++ b/apps/docs/src/app/(dashboard)/dashboard/page.tsx
@@ -123,7 +123,7 @@ export default function Dashboard() {
<div className="flex-1 md:pl-10">
<h2 className='text-2xl mb-2 font-bold'>{selectedItem[0].toUpperCase() + selectedItem.slice(1)}</h2>
<div className='border border-white/5 w-full h-[1px] mb-10' />
- <MainContent selectedItem={selectedItem} user={user} team={currentTeam} currentApiKey={currentApiKey} accessToken={accessToken} teams={teams} setTeams={setTeams} setCurrentTeam={setCurrentTeam} />
+ <MainContent selectedItem={selectedItem} user={user} team={currentTeam} currentApiKey={currentApiKey} accessToken={user.accessToken} teams={teams} setTeams={setTeams} setCurrentTeam={setCurrentTeam} />
</div>
</div>
)
@@ -171,7 +171,7 @@ const MenuItem = ({ icon: Icon, label, selected, onClick }: { icon: LucideIcon;
)
-const MainContent = ({ selectedItem, user, team, accessToken, currentApiKey, teams, setTeams, setCurrentTeam }: { selectedItem: MenuLabel, user: User, team: Team, accessToken: string | null, currentApiKey: string | null, teams: Team[], setTeams: (teams: Team[]) => void, setCurrentTeam: (team: Team) => void }) => {
+const MainContent = ({ selectedItem, user, team, accessToken, currentApiKey, teams, setTeams, setCurrentTeam }: { selectedItem: MenuLabel, user: User, team: Team, accessToken: string, currentApiKey: string | null, teams: Team[], setTeams: (teams: Team[]) => void, setCurrentTeam: (team: Team) => void }) => {
switch (selectedItem) {
case 'personal':
return <PersonalContent user={user} accessToken={accessToken} />
diff --git a/apps/docs/src/components/Dashboard/Personal.tsx b/apps/docs/src/components/Dashboard/Personal.tsx
index ba79d5018..13d5d3516 100644
--- a/apps/docs/src/components/Dashboard/Personal.tsx
+++ b/apps/docs/src/components/Dashboard/Personal.tsx
@@ -5,14 +5,30 @@ import { Button } from '../Button'
import { User } from '@supabase/supabase-js'
import Link from 'next/link'
import { useState } from 'react'
+import {Copy} from "lucide-react";
const updateUserUrl = `${process.env.NEXT_PUBLIC_BILLING_API_URL}/users`
-export const PersonalContent = ({user, accessToken}: {user: User, accessToken: string | null}) => {
+export const PersonalContent = ({user, accessToken}: {user: User, accessToken: string}) => {
const { toast } = useToast()
+ const [hovered, setHovered] = useState<boolean>(false)
const [email, setEmail] = useState(user.email)
+ const maskAccessToken = (key: string) => {
+ const firstSeven = key.slice(0, 7)
+ const lastFour = key.slice(-4)
+ const stars = '*'.repeat(key.length - 11) // use fixed-width character
+ return `${firstSeven}${stars}${lastFour}`
+ }
+
+ const copyToClipboard = (text: string) => {
+ navigator.clipboard.writeText(text)
+ toast({
+ title: 'Access token copied to clipboard',
+ })
+ }
+
const updateUserEmail = async() => {
if (!accessToken) {
return
@@ -50,38 +66,55 @@ export const PersonalContent = ({user, accessToken}: {user: User, accessToken: s
<h1 className="font-bold pb-10 text-xl">
Personal settings
</h1>
- <span className='text-neutral-300 pb-2'>Email:</span>
+
+ <span className='font-bold text-neutral-300 pb-2'>Email:</span>
<div className='flex w-full items-center space-x-2 pb-10'>
<input
- type="text"
- className="w-1/2 border border-white/10 text-sm focus:outline-none outline-none rounded-md p-2"
- placeholder={user.email}
- value={email}
- onChange={(e) => setEmail(e.target.value)}
+ type="text"
+ className="w-1/2 border border-white/10 text-sm focus:outline-none outline-none rounded-md p-2"
+ placeholder={user.email}
+ value={email}
+ onChange={(e) => setEmail(e.target.value)}
/>
<Button variant='outline' onClick={updateUserEmail}>Save changes</Button>
</div>
-
+
+
+ <span className='font-bold text-neutral-300 pb-2'>Access token:</span>
+ <span className='text-sm text-neutral-300 pb-4'>
+ This is your personal access token. It is used in CLI (e.g. for building new templates). You may need it for GitHub Actions or other CI/CD tools.
+ </span>
+ <div className='flex w-full justify-between items-center border border-white/5 rounded-lg p-2 mb-4 space-x-4'>
+ <div
+ className="font-mono cursor-pointer text-xs md:text-sm"
+ onMouseEnter={() => setHovered(true)}
+ onMouseLeave={() => setHovered(false)}
+ onClick={() => copyToClipboard(accessToken)}
+ >
+ {hovered ? accessToken : maskAccessToken(accessToken!)}
+ </div>
+ </div>
+
{user.app_metadata.provider === 'email' && (
- <>
- <h1 className="font-bold pb-4 text-xl">
- Reset password
- </h1>
- <span className='text-neutral-300 pb-4'>
+ <>
+ <h1 className="font-bold pb-4 text-xl">
+ Reset password
+ </h1>
+ <span className='text-neutral-300 pb-4'>
Resetting will send an email with a link to reset the password. <br/>
</span>
- <div className='flex items-center space-x-2 pb-10'>
- <Link href={'/sign-in?view=forgotten-password'}>
- <Button variant='desctructive'>
- Reset password
- </Button>
- </Link>
- </div>
- </>
+ <div className='flex items-center space-x-2 pb-10'>
+ <Link href={'/sign-in?view=forgotten-password'}>
+ <Button variant='desctructive'>
+ Reset password
+ </Button>
+ </Link>
+ </div>
+ </>
)}
- </div>
</div>
+ </div>
)
}