Skip to content

Commit

Permalink
feat: supabase auth, github oauth, session cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
gaboesquivel committed Apr 6, 2024
1 parent aeb71d2 commit 8ba60ba
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
18 changes: 9 additions & 9 deletions apps/masterbots.ai/components/user-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger
} from '@/components/ui/dropdown-menu'
import { User } from '@supabase/auth-js'
import { useSupabaseClient } from '@/services/supabase'
import { useGlobalStore } from '@/hooks/use-global-store'
import { UserProfile, useGlobalStore } from '@/hooks/use-global-store'

export function UserMenu() {
const supabase = useSupabaseClient()
Expand All @@ -24,20 +23,21 @@ export function UserMenu() {
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" className="pl-0">
{/* {user.image ? (
{user?.image ? (
<Image
className="transition-opacity duration-300 rounded-full select-none size-6 ring-1 ring-zinc-100/10 hover:opacity-80"
src={user?.image ? user.image : ''}
alt={user.name ?? 'Avatar'}
height={48}
width={48}
/>
) : (
<div className="flex items-center justify-center text-xs font-medium uppercase rounded-full select-none size-7 shrink-0 bg-muted/50 text-muted-foreground">
{user?.name ? getUserInitials(user?.name) : null}
</div> */}
) : (
<div className="flex items-center justify-center text-xs font-medium uppercase rounded-full select-none size-7 shrink-0 bg-muted/50 text-muted-foreground">
{user?.name ? getUserInitials(user?.name) : null}
</div>
)}

<span className="ml-2"> {user?.email}</span>
<span className="ml-2"> {user?.username}</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent sideOffset={8} align="start" className="w-[180px]">
Expand All @@ -60,5 +60,5 @@ function getUserInitials(name: string) {
return lastName ? `${firstName[0]}${lastName[0]}` : firstName.slice(0, 2)
}
export interface UserMenuProps {
user: User
user: UserProfile
}
8 changes: 2 additions & 6 deletions apps/masterbots.ai/hooks/use-global-store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ import { useSetState } from 'react-use'
const GlobalStoreContext = createContext<GlobalStoreContextValue>({
errorMessage: '',
hasuraJwt: '',
user: {
userId: '',
username: '',
name: '',
email: ''
},
user: null,
setGlobalError: (errorMessage: string) => {}
})

Expand Down Expand Up @@ -59,4 +54,5 @@ export type UserProfile = {
username: string
name: string
email: string
image: string
}
1 change: 0 additions & 1 deletion apps/masterbots.ai/services/hasura/hasura.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ export async function getUser({
const { user } = await client.query({
user: {
...everything,
name: true,
__args: {
where: {
email: {
Expand Down
3 changes: 2 additions & 1 deletion apps/masterbots.ai/services/supabase/supa-server.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export async function getUserProfile(): Promise<UserProfile | null> {
userId: userProfile.userId,
username: userProfile.username,
name: '',
email: userProfile.email
email: userProfile.email,
image: userProfile.profilePicture || ''
}
} catch (error) {
console.log('GET USER PROFILE ERROR', error)
Expand Down

0 comments on commit 8ba60ba

Please sign in to comment.