Migrate the existing login form to use React
This commit is contained in:
parent
0ab3768274
commit
d9f30294de
15 changed files with 322 additions and 72 deletions
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 a new issue