Update core smartproc
This commit is contained in:
48
src/auth.js
48
src/auth.js
@@ -13,12 +13,52 @@ export default {
|
||||
try {
|
||||
// Send request
|
||||
console.log(email, password);
|
||||
this._user = { ...defaultUser, email };
|
||||
// this._user = { ...defaultUser, email };
|
||||
|
||||
return {
|
||||
isOk: true,
|
||||
data: this._user
|
||||
// return {
|
||||
// isOk: true,
|
||||
// data: this._user
|
||||
// };
|
||||
|
||||
const requestOptions = {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ email: email, password: password }),
|
||||
};
|
||||
|
||||
const response = await fetch('http://localhost:9090/api/authentication/login', requestOptions);
|
||||
const data = await response.json();
|
||||
|
||||
console.log(data);
|
||||
//console.log(data.data.length);
|
||||
|
||||
// this._user = {
|
||||
// id: response.data.id,
|
||||
// email: response.data.role,
|
||||
// name: response.data.keterangan,
|
||||
// role_id: response.data.id,
|
||||
// };
|
||||
|
||||
if(data.status == 'sukses') {
|
||||
const defaultUser = {
|
||||
email: data.data.email,
|
||||
avatarUrl: 'https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/06.png',
|
||||
name: data.data.name,
|
||||
};
|
||||
this._user = { ...defaultUser };
|
||||
|
||||
return {
|
||||
isOk: true,
|
||||
data: this._user
|
||||
};
|
||||
} else {
|
||||
//--- jika gagal munculkan pesan gagal
|
||||
return {
|
||||
isOk: false,
|
||||
message: "Authentication failed"
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
catch {
|
||||
return {
|
||||
|
Reference in New Issue
Block a user