-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some changes to authentication + styling form_create page (#69)
lil changes in authentication
- Loading branch information
1 parent
3d5fa3e
commit 8a021a8
Showing
33 changed files
with
2,209 additions
and
224 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {NextRequest, NextResponse} from "next/server"; | ||
import {createClient} from "@/utils/supabase/server"; | ||
|
||
export async function GET(req: NextRequest) { | ||
const supabase = createClient() | ||
|
||
const { error } = await supabase.auth.signOut() | ||
|
||
if (error) { | ||
return NextResponse.json({ error: error.message }, { status: 500 }); | ||
} | ||
|
||
return NextResponse.json({ data: 'Logout successful' }, { status: 200 }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {NextRequest, NextResponse} from "next/server"; | ||
|
||
export async function POST(req: NextRequest): Promise<NextResponse> { | ||
let response = NextResponse.next({ | ||
request: { | ||
headers: req.headers, | ||
}, | ||
}) | ||
|
||
const body = await req.json() | ||
|
||
if ( !body.username ) { | ||
return NextResponse.json({ error: 'username is required' }) | ||
} | ||
|
||
let res = await fetch(`${process.env.NEXT_PUBLIC_SUPABASE_URL}/rest/v1/rpc/is_username_exist`, { | ||
method: 'POST', | ||
headers: { | ||
"apikey": process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!, | ||
"Authorization": `Bearer ${process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!}`, | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(body) | ||
}); | ||
|
||
let data = await res.json(); | ||
|
||
return NextResponse.json({ state: data }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import {NextRequest, NextResponse} from "next/server"; | ||
import { createClient } from "@/utils/supabase/server"; | ||
import { User } from "@supabase/supabase-js"; | ||
|
||
export async function POST(req: NextRequest): Promise<NextResponse> { | ||
let response = NextResponse.next({ | ||
request: { | ||
headers: req.headers, | ||
}, | ||
}) | ||
|
||
const body = await req.json() | ||
const supabase = createClient(); | ||
const searchParams = req.nextUrl.searchParams; | ||
const option = searchParams.get('option'); | ||
|
||
let data: User | User[] | null = null; | ||
|
||
if ( option === 'insert' ) { | ||
const { data: user, error: error } = await supabase | ||
.from('users') | ||
.insert([{id: body.id, username: body.username, admin: body.admin}]) | ||
if (error) { | ||
return NextResponse.json({ error: error.message }, { status: 500 }); | ||
} | ||
data = user; | ||
} else if ( option === 'update' ) { | ||
const { data: user, error: error } = await supabase | ||
.from('users') | ||
.update({username: body.username}) | ||
.match({id: body.id}) | ||
if (error) { | ||
return NextResponse.json({ error: error.message }, { status: 500 }); | ||
} | ||
data = user; | ||
} | ||
|
||
return NextResponse.json({ data: data }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
8a021a8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for iiitvcc ready!
✅ Preview
https://iiitvcc-gal9sq4bq-iiitv-coding-clubs-projects.vercel.app
Built with commit 8a021a8.
This pull request is being automatically deployed with vercel-action