File size: 1,081 Bytes
59f9574
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

import React, { useState } from "react";
import { supabase } from "../supabaseClient";

export default function ResetPassword() {

  const [password, setPassword] = useState("");
  const [loading, setLoading] = useState(false);

  const handleUpdate = async (e) => {
    e.preventDefault();
    setLoading(true);

    const { error } = await supabase.auth.updateUser({
      password: password
    });

    if (error) {
      alert(error.message);
    } else {
      alert("Password updated successfully!");
      window.location.href = "/";
    }

    setLoading(false);
  };

  return (
    <div style={{padding:"40px", color:"white"}}>

      <h2>Reset Your Password</h2>

      <form onSubmit={handleUpdate}>
        <input
          type="password"
          placeholder="Enter new password"
          value={password}
          onChange={(e)=>setPassword(e.target.value)}
          style={{padding:"10px", margin:"10px"}}
        />

        <button type="submit">
          {loading ? "Updating..." : "Update Password"}
        </button>

      </form>

    </div>
  );
}