Rework login page to be AJAX/Vue.js based
This commit is contained in:
23
app/assets/app/service/AuthApi.service.js
Normal file
23
app/assets/app/service/AuthApi.service.js
Normal file
@@ -0,0 +1,23 @@
|
||||
class AuthAPI {
|
||||
async validate_username(username) {
|
||||
const result = await axios.post('/api/v1/auth/validate/username', { username })
|
||||
return result && result.data && result.data.data && result.data.data.is_valid
|
||||
}
|
||||
|
||||
async attempt({ username, password, create_session }) {
|
||||
try {
|
||||
const result = await axios.post('/api/v1/auth/attempt', {
|
||||
username, password, create_session
|
||||
})
|
||||
|
||||
if ( result && result.data && result.data.data && result.data.data ) {
|
||||
return result.data.data
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
return { success: false }
|
||||
}
|
||||
}
|
||||
|
||||
const auth_api = new AuthAPI()
|
||||
export { auth_api }
|
||||
13
app/assets/app/service/Location.service.js
Normal file
13
app/assets/app/service/Location.service.js
Normal file
@@ -0,0 +1,13 @@
|
||||
class LocationService {
|
||||
async redirect(to, delay = 0) {
|
||||
return new Promise(res => {
|
||||
setTimeout(() => {
|
||||
window.location = to
|
||||
res()
|
||||
}, delay)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const location_service = new LocationService()
|
||||
export { location_service }
|
||||
Reference in New Issue
Block a user