This commit is contained in:
28
ayanova/src/api/auth.js
Normal file
28
ayanova/src/api/auth.js
Normal file
@@ -0,0 +1,28 @@
|
||||
/* Xeslint-disable */
|
||||
import apiUtil from "./apiutil";
|
||||
import { processLogin, processLogout } from "../utils/authutil";
|
||||
|
||||
export default {
|
||||
async authenticate(login, password) {
|
||||
return fetch(
|
||||
apiUtil.APIUrl("auth"),
|
||||
apiUtil.fetchPostNoAuthOptions({
|
||||
login: login,
|
||||
password: password
|
||||
})
|
||||
)
|
||||
.then(apiUtil.status)
|
||||
.then(apiUtil.json)
|
||||
.then(processLogin)
|
||||
.then(() => {
|
||||
return Promise.resolve(true);
|
||||
}) //succeeded, nothing to return
|
||||
.catch(function(error) {
|
||||
processLogout();
|
||||
return Promise.reject(error);
|
||||
});
|
||||
},
|
||||
logout() {
|
||||
processLogout();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user