mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-17 05:43:45 +02:00
Migrate the existing login form to use React
This commit is contained in:
25
resources/scripts/api/auth/login.ts
Normal file
25
resources/scripts/api/auth/login.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import http from '@/api/http';
|
||||
|
||||
interface LoginResponse {
|
||||
complete: boolean;
|
||||
intended?: string;
|
||||
token?: string;
|
||||
}
|
||||
|
||||
export default (user: string, password: string): Promise<LoginResponse> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.post('/auth/login', { user, password })
|
||||
.then(response => {
|
||||
if (!(response.data instanceof Object)) {
|
||||
return reject(new Error('An error occurred while processing the login request.'));
|
||||
}
|
||||
|
||||
return resolve({
|
||||
complete: response.data.complete,
|
||||
intended: response.data.intended || undefined,
|
||||
token: response.data.token || undefined,
|
||||
});
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user