dvc890 commited on
Commit
b4dc55a
·
verified ·
1 Parent(s): 833c7c4

Update services/api.ts

Browse files
Files changed (1) hide show
  1. services/api.ts +16 -0
services/api.ts CHANGED
@@ -97,6 +97,22 @@ export const api = {
97
  }
98
  }
99
  return null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  }
101
  },
102
 
 
97
  }
98
  }
99
  return null;
100
+ },
101
+ verifyPassword: async (password: string): Promise<boolean> => {
102
+ const currentUser = api.auth.getCurrentUser();
103
+ if (!currentUser) return false;
104
+ try {
105
+ // Use login endpoint to verify password without affecting session if possible,
106
+ // but api.auth.login has side effects (localStorage).
107
+ // So we use the raw request method to hit the endpoint directly.
108
+ await request('/auth/login', {
109
+ method: 'POST',
110
+ body: JSON.stringify({ username: currentUser.username, password })
111
+ });
112
+ return true;
113
+ } catch (e) {
114
+ return false;
115
+ }
116
  }
117
  },
118