Skip to content

Commit e405253

Browse files
authored
Revert "sso login change password send link for email" (#533)
Revert "sso login change password send link for email (#532)" This reverts commit 734b5aa.
1 parent 734b5aa commit e405253

File tree

6 files changed

+89
-221
lines changed

6 files changed

+89
-221
lines changed

app/(dashboard)/components/Icons/BrokenCircleCheckIcon.tsx

Lines changed: 0 additions & 31 deletions
This file was deleted.

app/(dashboard)/settings/components/PasswordForm.tsx

Lines changed: 88 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,10 @@ import { PasswordField } from "components/FormElementsv2/PasswordField/PasswordF
1717

1818
import FormHeader from "./FormHeader";
1919
import { FieldCell, FieldTitleCell, PasswordValidationSchema } from "./Common";
20-
import { customerUserResetPassword } from "src/api/customer-user";
21-
import { Box, CircularProgress } from "@mui/material";
22-
import Divider from "src/components/Divider/Divider";
23-
import BrokenCircleCheckIcon from "app/(dashboard)/components/Icons/BrokenCircleCheckIcon";
2420

25-
type PasswordFormProps = {
26-
email: string;
27-
};
28-
29-
const PasswordForm: React.FC<PasswordFormProps> = ({ email }) => {
21+
const PasswordForm = () => {
3022
const snackbar = useSnackbar();
3123
const { logout } = useLogout();
32-
const loggedInUsingSSO = localStorage.getItem("loggedInUsingSSO");
33-
34-
const isLoggedInUsingSSO = loggedInUsingSSO === "true";
3524

3625
const updatePasswordMutation = useMutation(
3726
(data: any) =>
@@ -69,173 +58,95 @@ const PasswordForm: React.FC<PasswordFormProps> = ({ email }) => {
6958

7059
const { values, handleChange, handleBlur, touched, errors } = formData;
7160

72-
const setPasswordMutation = useMutation(
73-
() => {
74-
const payload = { email: email };
75-
return customerUserResetPassword(payload);
76-
},
77-
{
78-
onSuccess: () => {
79-
snackbar.showSuccess(
80-
"We have emailed you a link to set your password. Please check your email and follow the instructions."
81-
);
82-
},
83-
}
84-
);
85-
86-
const handleSetPassword = () => {
87-
setPasswordMutation.mutate();
88-
};
89-
if (!isLoggedInUsingSSO) {
90-
return (
91-
<div>
92-
<FormHeader
93-
title="Password"
94-
description="Please enter your current password to change your password"
95-
className="pb-5 mb-6 border-b border-[#E9EAEB]"
96-
/>
97-
98-
{/* @ts-ignore */}
99-
<Form onSubmit={formData.handleSubmit}>
100-
<div className="grid grid-cols-1 lg:grid-cols-4 gap-y-5">
101-
<FieldTitleCell>
102-
<FieldTitle required>Current Password</FieldTitle>
103-
</FieldTitleCell>
104-
<FieldCell>
105-
<PasswordField
106-
name="currentPassword"
107-
id="currentPassword"
108-
value={values.currentPassword}
109-
onChange={handleChange}
110-
onBlur={handleBlur}
111-
sx={{ mt: 0 }}
112-
/>
113-
<FieldError>
114-
{touched.currentPassword && errors.currentPassword}
115-
</FieldError>
116-
</FieldCell>
117-
118-
<FieldTitleCell>
119-
<FieldTitle required>New Password</FieldTitle>
120-
</FieldTitleCell>
121-
<FieldCell>
122-
<Text
123-
size="small"
124-
weight="regular"
125-
color="#535862"
126-
sx={{ mb: "6px" }}
127-
>
128-
Your new password must be more than 8 characters
129-
</Text>
130-
<PasswordField
131-
name="newPassword"
132-
id="newPassword"
133-
value={values.newPassword}
134-
onChange={handleChange}
135-
onBlur={handleBlur}
136-
sx={{ mt: 0 }}
137-
/>
138-
<FieldError>
139-
{touched.newPassword && errors.newPassword}
140-
</FieldError>
141-
</FieldCell>
142-
143-
<FieldTitleCell>
144-
<FieldTitle required>Confirm Password</FieldTitle>
145-
</FieldTitleCell>
146-
<FieldCell>
147-
<PasswordField
148-
name="confirmPassword"
149-
id="confirmPassword"
150-
value={values.confirmPassword}
151-
onChange={handleChange}
152-
onBlur={handleBlur}
153-
sx={{ mt: 0 }}
154-
/>
155-
<FieldError>
156-
{touched.confirmPassword && errors.confirmPassword}
157-
</FieldError>
158-
</FieldCell>
159-
</div>
160-
161-
<div className="flex items-center justify-end gap-4 mt-5">
162-
<Button
163-
variant="outlined"
164-
onClick={() => formData.resetForm()}
165-
disabled={updatePasswordMutation.isLoading}
166-
>
167-
Cancel
168-
</Button>
169-
<Button
170-
type="submit"
171-
variant="contained"
172-
disabled={updatePasswordMutation.isLoading}
173-
>
174-
Save
175-
{updatePasswordMutation.isLoading && <LoadingSpinnerSmall />}
176-
</Button>
177-
</div>
178-
</Form>
179-
</div>
180-
);
181-
}
182-
183-
if (isLoggedInUsingSSO) {
184-
return (
185-
<Box sx={{ Padding: "100px" }} display="flex" flexDirection={"column"}>
186-
<Box display="flex" justifyContent={"center"}>
187-
<Box
188-
display="flex"
189-
gap={1}
190-
mt="2px"
191-
textAlign={"center"}
192-
alignItems={"center"}
193-
>
194-
<BrokenCircleCheckIcon color="#079455" />
195-
196-
<Text size="xlarge" weight="regular" color="rgba(83, 88, 98, 1)">
197-
You are currently logged in via Google/Github SSO.
198-
</Text>
199-
</Box>
200-
</Box>
201-
<Box display="flex" justifyContent={"center"}>
202-
<Box display="flex" gap={1} mt="2px">
203-
<Text size="xlarge" weight="regular" color="rgba(83, 88, 98, 1)">
204-
To setup password-based access, please
205-
</Text>
206-
<Button
207-
onClick={handleSetPassword}
208-
sx={{
209-
color: "#7F56D9 !important",
210-
fontSize: "20px !important",
211-
lineHeight: "30px !important",
212-
fontWeight: 700,
213-
textDecoration: "underline !important",
214-
textUnderlineOffset: "2px",
215-
cursor: "pointer",
216-
background: "none",
217-
border: "none",
218-
padding: "0 !important",
219-
}}
220-
disabled={setPasswordMutation.isLoading}
61+
return (
62+
<div>
63+
<FormHeader
64+
title="Password"
65+
description="Please enter your current password to change your password"
66+
className="pb-5 mb-6 border-b border-[#E9EAEB]"
67+
/>
68+
69+
{/* @ts-ignore */}
70+
<Form onSubmit={formData.handleSubmit}>
71+
<div className="grid grid-cols-1 lg:grid-cols-4 gap-y-5">
72+
<FieldTitleCell>
73+
<FieldTitle required>Current Password</FieldTitle>
74+
</FieldTitleCell>
75+
<FieldCell>
76+
<PasswordField
77+
name="currentPassword"
78+
id="currentPassword"
79+
value={values.currentPassword}
80+
onChange={handleChange}
81+
onBlur={handleBlur}
82+
sx={{ mt: 0 }}
83+
/>
84+
<FieldError>
85+
{touched.currentPassword && errors.currentPassword}
86+
</FieldError>
87+
</FieldCell>
88+
89+
<FieldTitleCell>
90+
<FieldTitle required>New Password</FieldTitle>
91+
</FieldTitleCell>
92+
<FieldCell>
93+
<Text
94+
size="small"
95+
weight="regular"
96+
color="#535862"
97+
sx={{ mb: "6px" }}
22198
>
222-
click here
223-
</Button>
224-
225-
<Text size="xlarge" weight="regular" color="rgba(83, 88, 98, 1)">
226-
to send a setup link
99+
Your new password must be more than 8 characters
227100
</Text>
228-
</Box>
229-
</Box>
230-
<Box display="flex" justifyContent={"center"}>
231-
{setPasswordMutation.isLoading && (
232-
<CircularProgress size={16} sx={{ marginLeft: "8px" }} />
233-
)}
234-
</Box>
235-
<Divider sx={{ mt: 3, mb: 3 }} />
236-
</Box>
237-
);
238-
}
101+
<PasswordField
102+
name="newPassword"
103+
id="newPassword"
104+
value={values.newPassword}
105+
onChange={handleChange}
106+
onBlur={handleBlur}
107+
sx={{ mt: 0 }}
108+
/>
109+
<FieldError>{touched.newPassword && errors.newPassword}</FieldError>
110+
</FieldCell>
111+
112+
<FieldTitleCell>
113+
<FieldTitle required>Confirm Password</FieldTitle>
114+
</FieldTitleCell>
115+
<FieldCell>
116+
<PasswordField
117+
name="confirmPassword"
118+
id="confirmPassword"
119+
value={values.confirmPassword}
120+
onChange={handleChange}
121+
onBlur={handleBlur}
122+
sx={{ mt: 0 }}
123+
/>
124+
<FieldError>
125+
{touched.confirmPassword && errors.confirmPassword}
126+
</FieldError>
127+
</FieldCell>
128+
</div>
129+
130+
<div className="flex items-center justify-end gap-4 mt-5">
131+
<Button
132+
variant="outlined"
133+
onClick={() => formData.resetForm()}
134+
disabled={updatePasswordMutation.isLoading}
135+
>
136+
Cancel
137+
</Button>
138+
<Button
139+
type="submit"
140+
variant="contained"
141+
disabled={updatePasswordMutation.isLoading}
142+
>
143+
Save
144+
{updatePasswordMutation.isLoading && <LoadingSpinnerSmall />}
145+
</Button>
146+
</div>
147+
</Form>
148+
</div>
149+
);
239150
};
240151

241152
export default PasswordForm;

app/(dashboard)/settings/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const SettingsPage = () => {
109109
isLoadingUserData={isLoadingUserData}
110110
/>
111111
)}
112-
{currentTab === "password" && <PasswordForm email={selectUser.email} />}
112+
{currentTab === "password" && <PasswordForm />}
113113
</PageContainer>
114114
</div>
115115
);

app/(public)/(main-image)/signin/components/SigninPage.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ const SigninPage = (props) => {
8383

8484
if (jwtToken) {
8585
Cookies.set("token", jwtToken, { sameSite: "Lax", secure: true });
86-
try {
87-
localStorage.removeItem("loggedInUsingSSO");
88-
} catch (error) {
89-
console.warn("Failed to clear SSO state:", error);
90-
}
9186
axios.defaults.headers["Authorization"] = "Bearer " + jwtToken;
9287

9388
// Redirect to the Destination URL

app/(public)/idp-auth/page.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ const IDPAuthPage = () => {
3232
Cookies.set("token", jwtToken, { sameSite: "Lax", secure: true });
3333
axios.defaults.headers["Authorization"] = "Bearer " + jwtToken;
3434

35-
try {
36-
localStorage.setItem("loggedInUsingSSO", "true");
37-
} catch (error) {
38-
console.warn("Failed to set SSO state:", error);
39-
}
40-
4135
// Redirect to the Destination URL
4236
if (destination && PAGE_TITLE_MAP[destination]) {
4337
router.replace(decodeURIComponent(destination));

src/hooks/useLogout.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ function useLogout() {
1717
function handleLogout() {
1818
Cookies.remove("token");
1919
localStorage.removeItem("paymentNotificationHidden");
20-
localStorage.removeItem("loggedInUsingSSO");
2120
router.replace("/signin");
2221
}
2322

0 commit comments

Comments
 (0)