Skip to content

Commit 34a56a9

Browse files
committed
fixing login with 2fa
1 parent 8f45bdb commit 34a56a9

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

src/pages/LoginWith2fa.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ export const LOGIN_WITH_2FA = gql`
4242
mutation LoginWithTwoFactorAuthentication(
4343
$email: String!
4444
$otp: String!
45-
$TwoWayVerificationToken: String!
45+
# $TwoWayVerificationToken: String!
4646
) {
4747
loginWithTwoFactorAuthentication(
4848
email: $email
4949
otp: $otp
50-
TwoWayVerificationToken: $TwoWayVerificationToken
50+
# TwoWayVerificationToken: $TwoWayVerificationToken
5151
) {
5252
token
5353
user {
@@ -84,7 +84,7 @@ const TwoFactorPage: React.FC = () => {
8484

8585
const location = useLocation();
8686
const navigate = useNavigate();
87-
const { email, TwoWayVerificationToken } = location.state || {};
87+
const { email } = location.state || {};
8888
useEffect(() => {
8989
// Update document class and localStorage when theme changes
9090
if (isDark) {
@@ -97,30 +97,30 @@ const TwoFactorPage: React.FC = () => {
9797
}, [isDark]);
9898

9999
useEffect(() => {
100-
if (!email || !TwoWayVerificationToken) {
100+
if (!email ) {
101101
navigate('/login');
102102
}
103-
}, [email, TwoWayVerificationToken, navigate]);
103+
}, [email, navigate]);
104104

105105
const [loginWithTwoFactorAuthentication] = useMutation<LoginResponse>(
106106
LOGIN_WITH_2FA,
107107
{
108108
onCompleted: async (data) => {
109109
const response = data.loginWithTwoFactorAuthentication;
110110
try {
111-
localStorage.setItem('authToken', response.token);
111+
//localStorage.setItem('authToken', response.token);
112112
localStorage.setItem('user', JSON.stringify(response.user));
113113
await login(response);
114114
await client.resetStore();
115115
toast.success(response.message);
116116

117117
const rolePaths: Record<string, string> = {
118-
superAdmin: '/dashboard',
118+
superAdmin: '/organizations',
119119
admin: '/trainees',
120120
coordinator: '/trainees',
121121
manager: '/dashboard',
122122
ttl: '/ttl-trainees',
123-
trainee: '/dashboard',
123+
trainee: '/performance',
124124
};
125125

126126
const redirectPath = rolePaths[response.user.role] || '/dashboard';
@@ -152,7 +152,7 @@ const TwoFactorPage: React.FC = () => {
152152
variables: {
153153
email,
154154
otp: currentInput.join(''),
155-
TwoWayVerificationToken,
155+
// TwoWayVerificationToken,
156156
},
157157
});
158158
} finally {

src/pages/Organization/AdminLogin.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ function AdminLogin() {
2727
const orgName: any = localStorage.getItem('orgName');
2828
const [loading, setLoading] = useState(false);
2929
const [otpRequired, setOtpRequired] = useState(false);
30-
const [TwoWayVerificationToken, setTwoWayVerificationToken] = useState('');
3130
const [otp, setOtp] = useState('');
3231

3332
useDocumentTitle('Login');
@@ -79,11 +78,11 @@ function AdminLogin() {
7978
onCompleted: async (data) => {
8079
if (data.loginUser.otpRequired) {
8180
setOtpRequired(true);
82-
setTwoWayVerificationToken(data.loginUser.TwoWayVerificationToken);
81+
8382
navigate('/users/LoginWith2fa', {
8483
state: {
8584
email: userInput.email,
86-
TwoWayVerificationToken: data.loginUser.TwoWayVerificationToken,
85+
8786
},
8887
});
8988
} else {
@@ -345,4 +344,4 @@ function AdminLogin() {
345344
);
346345
}
347346

348-
export default AdminLogin;
347+
export default AdminLogin;

src/pages/Organization/LoginMutation.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const LOGIN_MUTATION = gql`
55
loginUser(loginInput: $loginInput) {
66
token
77
otpRequired
8-
TwoWayVerificationToken
8+
99
user {
1010
id
1111
role

0 commit comments

Comments
 (0)