MCPcopy Create free account
hub / github.com/codemistic/Web-Development / Login

Function Login

Yet Another LinkedIn Clone/Login.js:8–111  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6import "./Login.css";
7
8const Login = () => {
9 const [email, setEmail] = useState("");
10 const [password, setPassword] = useState("");
11 const [name, setName] = useState("");
12 const [profilePic, setProfilePic] = useState("");
13 const dispatch = useDispatch();
14
15 const loginHandler = async (e) => {
16 e.preventDefault();
17 try {
18 const userAuth = await auth.signInWithEmailAndPassword(email, password);
19
20 dispatch(
21 login({
22 email: userAuth.user.email,
23 uid: userAuth.user.uid,
24 displayName: userAuth.user.displayName,
25 photoUrl: userAuth.user.photoURL,
26 })
27 );
28 } catch (error) {
29 alert(error);
30 }
31 };
32
33 const registerHandler = async () => {
34 if (!name) {
35 return alert("Please enter a full name!");
36 }
37
38 try {
39 const userAuth = await auth.createUserWithEmailAndPassword(
40 email,
41 password
42 );
43
44 await userAuth.user.updateProfile({
45 displayName: name,
46 photoUrl: profilePic,
47 });
48
49 dispatch(
50 login({
51 email: userAuth.user.email,
52 uid: userAuth.user.uid,
53 displayName: name,
54 photoUrl: profilePic,
55 })
56 );
57 } catch (error) {
58 console.log(error);
59 alert(error);
60 }
61 };
62
63 return (
64 <div className="login">
65 <img

Callers 1

App.jsFile · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected