Skip to content
Snippets Groups Projects
Commit 7ba24c3a authored by Ganapathi Subramanyam  Jayam's avatar Ganapathi Subramanyam Jayam :dart:
Browse files

updated forgot password

parent 0b1736c2
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ import copyright from './user/copyright' ...@@ -10,6 +10,7 @@ import copyright from './user/copyright'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { Container, Button, Navbar, Nav } from 'react-bootstrap' import { Container, Button, Navbar, Nav } from 'react-bootstrap'
import fire from './fire' import fire from './fire'
import ForgotPassword from "./user/ForgotPassword"
const Routes = () => { const Routes = () => {
...@@ -51,6 +52,7 @@ const Routes = () => { ...@@ -51,6 +52,7 @@ const Routes = () => {
<Route path='/' exact component={Signin} /> <Route path='/' exact component={Signin} />
<Route path='/signin' exact component={Signin} /> <Route path='/signin' exact component={Signin} />
<Route path='/copyright' exact component={copyright} /> <Route path='/copyright' exact component={copyright} />
<Route path='/forgot-password' component={ForgotPassword} />
</Switch> </Switch>
<Navbar fixed='bottom' variant='light' bg='light'> <Navbar fixed='bottom' variant='light' bg='light'>
<Container className='ml-sm-2'> <Container className='ml-sm-2'>
......
import React, { useState, useEffect } from 'react'
import { Link } from 'react-router-dom'
import fire from '../fire'
import firebase from 'firebase'
export default function ForgotPassword() {
const [email, setEmail] = useState('')
const [emailError, setEmailError] = useState('')
const clearErrors = () => {
setEmailError('')
setEmail('')
}
const handleforgot = () => {
clearErrors()
fire
.auth()
.sendPasswordResetEmail(email)
.catch((e) => {
setEmailError(e.message)
})
setEmailError('Check your inbox for furthur instructions')
}
return (
<section className='login'>
<div className='loginContainer'>
<p className='errorMsg'>{emailError}</p>
<label>UserName</label>
<input
type='text'
autoFocus
required
value={email}
onChange={(e) => setEmail(e.target.value)}
></input>
<div className='btnContainer'>
<button onClick={handleforgot}>Reset Password</button>
<p>
Have an account ?{' '}
<Link to='/signin'>
<span>Sign in</span>
</Link>
</p>
</div>
</div>
</section>
)
}
import React from 'react' import React, { useState, useEffect } from 'react'
import GoogleButton from 'react-google-button' import GoogleButton from 'react-google-button'
import GithubButton from 'react-github-login-button' import GithubButton from 'react-github-login-button'
import { Link } from 'react-router-dom'
import Loader from 'react-loader-spinner'
const Login = (props) => { const Login = (props) => {
const { const {
...@@ -16,7 +19,27 @@ const Login = (props) => { ...@@ -16,7 +19,27 @@ const Login = (props) => {
passwordError, passwordError,
googlesignin, googlesignin,
githubsignin, githubsignin,
loading,
} = props } = props
useEffect(() => {
if (loading) {
return (
<>
<div className='centered'>
<Loader
type='Puff'
color='#00BFFF'
height={100}
width={100}
timeout={3000} //3 secs
/>
</div>
</>
)
}
}, [loading])
return ( return (
<section className='login'> <section className='login'>
<div className='loginContainer'> <div className='loginContainer'>
...@@ -41,6 +64,9 @@ const Login = (props) => { ...@@ -41,6 +64,9 @@ const Login = (props) => {
{hasAccount ? ( {hasAccount ? (
<> <>
<button onClick={handleLogin}>Sign In</button> <button onClick={handleLogin}>Sign In</button>
<div className='w-100 text-center mt-3'>
<Link to='/forgot-password'>Forgot Password</Link>
</div>
<p> <p>
Don't have an account ?{' '} Don't have an account ?{' '}
<span onClick={() => setHasAccount(!hasAccount)}>Sign up</span> <span onClick={() => setHasAccount(!hasAccount)}>Sign up</span>
...@@ -49,24 +75,22 @@ const Login = (props) => { ...@@ -49,24 +75,22 @@ const Login = (props) => {
<GoogleButton onClick={googlesignin} /> <GoogleButton onClick={googlesignin} />
<p></p> <p></p>
<GithubButton <GithubButton onClick={githubsignin} />
onClick={githubsignin}
/>
</> </>
) : ( ) : (
<> <>
<button onClick={handleSignup}>Sign up</button> <button onClick={handleSignup}>Sign up</button>
<p> <p>
Have an account ?{' '} Have an account ?{' '}
<span onClick={() => setHasAccount(!hasAccount)}>Sign in</span> <span onClick={() => setHasAccount(!hasAccount)}>Sign in</span>
</p> </p>
<p></p> <p></p>
<GoogleButton onClick={googlesignin} /> <GoogleButton onClick={googlesignin} />
<p></p> <p></p>
<GithubButton <GithubButton onClick={githubsignin} />
onClick={githubsignin}
/>
</> </>
)} )}
</div> </div>
......
...@@ -12,6 +12,7 @@ const Signin = () => { ...@@ -12,6 +12,7 @@ const Signin = () => {
const [emailError, setEmailError] = useState('') const [emailError, setEmailError] = useState('')
const [passwordError, setPasswordError] = useState('') const [passwordError, setPasswordError] = useState('')
const [hasAccount, setHasAccount] = useState(false) const [hasAccount, setHasAccount] = useState(false)
const [loading, setloading] = useState(false)
const githubsignin = () => { const githubsignin = () => {
var provider = new firebase.auth.GithubAuthProvider() var provider = new firebase.auth.GithubAuthProvider()
...@@ -81,7 +82,10 @@ const Signin = () => { ...@@ -81,7 +82,10 @@ const Signin = () => {
setPasswordError('') setPasswordError('')
} }
const handleLogin = () => { const handleLogin = () => {
setloading(true)
clearErrors() clearErrors()
fire fire
.auth() .auth()
...@@ -98,6 +102,7 @@ const Signin = () => { ...@@ -98,6 +102,7 @@ const Signin = () => {
break break
} }
}) })
setloading(false)
} }
const handleSignup = () => { const handleSignup = () => {
...@@ -155,6 +160,7 @@ const Signin = () => { ...@@ -155,6 +160,7 @@ const Signin = () => {
passwordError={passwordError} passwordError={passwordError}
googlesignin={googlesignin} googlesignin={googlesignin}
githubsignin={githubsignin} githubsignin={githubsignin}
loading={loading}
/> />
)} )}
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment