Skip to content

Commit

Permalink
adding reset-password
Browse files Browse the repository at this point in the history
  • Loading branch information
Anas-github-acc committed Jul 29, 2024
2 parents e2540a8 + 06f7d6a commit b31e86f
Show file tree
Hide file tree
Showing 24 changed files with 912 additions and 38 deletions.
160 changes: 159 additions & 1 deletion package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@emotion/styled": "^11.12.0",
"@mui/material": "^5.16.4",
"@radix-ui/react-avatar": "^1.1.0",
"@radix-ui/react-checkbox": "^1.1.1",
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-dropdown-menu": "^2.1.1",
"@radix-ui/react-icons": "^1.3.0",
Expand Down
Binary file added public/facebook-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/facebook-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/home/placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/instagram-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/instagram-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/linkedin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/linkedin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/twitter-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/twitter-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions src/app/api/update-password/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {NextRequest, NextResponse} from "next/server";
import { cookies } from 'next/headers';
import {createClient} from "@/utils/supabase/server";

export async function GET(req: NextRequest) {
const requestUrl = new URL(req.nextUrl.href)
const code = requestUrl.searchParams.get('code')

if( code ) {
const supabase = createClient()
const { error } = await supabase.auth.exchangeCodeForSession(code)

return NextResponse.redirect(new URL(`${req.nextUrl.origin}/auth/update_password`, req.nextUrl.href))
}

console.log({error : 'ERROR: Invalid auth code or no auth code found'}, { status: 500 })

return NextResponse.redirect(new URL(`${req.nextUrl.origin}/auth`, req.nextUrl.href))
}
21 changes: 21 additions & 0 deletions src/app/auth/component/component.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React, { FormEvent, use, useEffect, useState } from "react";
import Link from "next/link";
import axios from "axios";

import { Label } from "@/components/ui/label"
import { Input } from "@/components/ui/input"
import { Button } from "@/components/ui/button"
import { Checkbox } from "@/components/ui/checkbox"
import Loader from '@/components/ui/loader'

import { VscEye, VscEyeClosed } from "react-icons/vsc"
Expand Down Expand Up @@ -165,6 +167,25 @@ export function Component( props : Props) {
<i className={`${!(input.name === 'password') && 'hidden'} ${styles.inputicon} ${styles.eyeicon}`} onClick={() => setRevealPassword(!revealPassword)}>{revealPassword?<VscEyeClosed size='23px'/>:<VscEye size='23px'/>}</i>
</div>
))}

{auth === 'login' &&
<div className="flex items-center justify-between">
<div className="flex items-center">
<Checkbox
id="remember-me"
name="remember-me"
className="h-4 w-4 rounded text-primary focus:ring-primary"
/>
<Label htmlFor="remember-me" className="ml-2 block text-sm text-foreground">
Remember me
</Label>
</div>
<div className="text-sm">
<Link href="auth/reset_password" className="font-medium text-primary hover:text-primary/80" prefetch={false}>
Forgot your password?
</Link>
</div>
</div>}
<div>
<Button
type="submit"
Expand Down
5 changes: 5 additions & 0 deletions src/app/auth/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ export default function Auth(){
</div>)}

{oauthhidden && <OAuthComponent onClick={Authsignin} />}
<div className="text-center text-sm text-muted-foreground">
<Link href="/home" className="font-medium hover:underline" prefetch={false}>
Back to Home
</Link>
</div>
</Component>
</Suspense>
)
Expand Down
Loading

0 comments on commit b31e86f

Please sign in to comment.