Add web linting
This commit is contained in:
parent
64b124b37e
commit
4f6b652660
@ -4,7 +4,8 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "vite --port 3800",
|
||||
"build": "vite build"
|
||||
"build": "vite build",
|
||||
"lint": "standard --fix"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mdi/font": "^7.0.96",
|
||||
@ -16,6 +17,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.1.4",
|
||||
"standard": "^17.1.2",
|
||||
"vite": "^5.4.8",
|
||||
"vue-template-compiler": "^2.7.16"
|
||||
},
|
||||
|
@ -1,45 +1,45 @@
|
||||
const hosts = {
|
||||
'development': 'http://localhost:3801',
|
||||
'production': 'https://api.sso.tools',
|
||||
};
|
||||
development: 'http://localhost:3801',
|
||||
production: 'https://api.sso.tools'
|
||||
}
|
||||
|
||||
export const api = {
|
||||
|
||||
token: null,
|
||||
|
||||
req(method, path, data, success, fail) {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open(method, `${hosts[process.env.NODE_ENV]}${path}`);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
req (method, path, data, success, fail) {
|
||||
const xhr = new window.XMLHttpRequest()
|
||||
xhr.open(method, `${hosts[process.env.NODE_ENV]}${path}`)
|
||||
xhr.setRequestHeader('Content-Type', 'application/json')
|
||||
if (api.token) {
|
||||
xhr.setRequestHeader('Authorization', `Bearer ${api.token}`);
|
||||
xhr.setRequestHeader('Authorization', `Bearer ${api.token}`)
|
||||
}
|
||||
xhr.onreadystatechange = () => {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.status === 200) {
|
||||
let response;
|
||||
try { response = JSON.parse(xhr.responseText); } catch (err) { console.log(err); }
|
||||
if (success) success(response);
|
||||
let response
|
||||
try { response = JSON.parse(xhr.responseText) } catch (err) { console.log(err) }
|
||||
if (success) success(response)
|
||||
} else {
|
||||
if (xhr.status === 401) {
|
||||
return fail && fail({ status: 401, message: 'Authorisation is needed' });
|
||||
return fail && fail({ status: 401, message: 'Authorisation is needed' })
|
||||
}
|
||||
let message;
|
||||
try { message = JSON.parse(xhr.responseText).message; } catch (err) { if (fail) fail({ status: xhr.status, message: 'There was a problem with this request' }); }
|
||||
if (fail) fail({ status: xhr.status, message });
|
||||
let message
|
||||
try { message = JSON.parse(xhr.responseText).message } catch (err) { if (fail) fail({ status: xhr.status, message: 'There was a problem with this request' }) }
|
||||
if (fail) fail({ status: xhr.status, message })
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.send(data && JSON.stringify(data));
|
||||
}
|
||||
xhr.send(data && JSON.stringify(data))
|
||||
},
|
||||
|
||||
unauthenticatedRequest(method, path, data, success, fail, options) {
|
||||
api.req(method, path, data, success, fail, false, options);
|
||||
unauthenticatedRequest (method, path, data, success, fail, options) {
|
||||
api.req(method, path, data, success, fail, false, options)
|
||||
},
|
||||
|
||||
authenticatedRequest(method, path, data, success, fail, options ) {
|
||||
api.req(method, path, data, success, fail, true, options);
|
||||
},
|
||||
};
|
||||
authenticatedRequest (method, path, data, success, fail, options) {
|
||||
api.req(method, path, data, success, fail, true, options)
|
||||
}
|
||||
}
|
||||
|
||||
export default api;
|
||||
export default api
|
||||
|
106
web/src/main.js
106
web/src/main.js
@ -10,66 +10,66 @@ import '@mdi/font/css/materialdesignicons.css'
|
||||
|
||||
import App from './App.vue'
|
||||
|
||||
import Home from './components/Home.vue';
|
||||
import ResetPassword from './components/ResetPassword.vue';
|
||||
import Account from './components/Account.vue';
|
||||
import Home from './components/Home.vue'
|
||||
import ResetPassword from './components/ResetPassword.vue'
|
||||
import Account from './components/Account.vue'
|
||||
import Dashboard from './components/Dashboard.vue'
|
||||
import Root from './components/Root.vue'
|
||||
import NewIDP from './components/NewIDP.vue'
|
||||
import IDP from './components/IDP.vue';
|
||||
import IDPHome from './components/IdpHome.vue';
|
||||
import IDPUsers from './components/IdpUsers.vue';
|
||||
import IDPSettings from './components/IdpSettings.vue';
|
||||
import IDPSPs from './components/IdpSps.vue';
|
||||
import IDPSAML from './components/IdpSaml.vue';
|
||||
import IDPSAMLLogs from './components/IdpSamlLogs.vue';
|
||||
import IDPOAuth from './components/IdpOauth.vue';
|
||||
import IDPOAuthGuide from './components/IdpOauthGuide.vue';
|
||||
import IDPSaml2Guide from './components/IdpSaml2Guide.vue';
|
||||
import IDPOAuthLogs from './components/IdpOauthLogs.vue';
|
||||
import GuideLayout from './components/Guide.vue';
|
||||
import IDP from './components/IDP.vue'
|
||||
import IDPHome from './components/IdpHome.vue'
|
||||
import IDPUsers from './components/IdpUsers.vue'
|
||||
import IDPSettings from './components/IdpSettings.vue'
|
||||
import IDPSPs from './components/IdpSps.vue'
|
||||
import IDPSAML from './components/IdpSaml.vue'
|
||||
import IDPSAMLLogs from './components/IdpSamlLogs.vue'
|
||||
import IDPOAuth from './components/IdpOauth.vue'
|
||||
import IDPOAuthGuide from './components/IdpOauthGuide.vue'
|
||||
import IDPSaml2Guide from './components/IdpSaml2Guide.vue'
|
||||
import IDPOAuthLogs from './components/IdpOauthLogs.vue'
|
||||
import GuideLayout from './components/Guide.vue'
|
||||
|
||||
import PrivacyPolicy from './components/legal/PrivacyPolicy.vue';
|
||||
import TermsOfUse from './components/legal/TermsOfUse.vue';
|
||||
import PrivacyPolicy from './components/legal/PrivacyPolicy.vue'
|
||||
import TermsOfUse from './components/legal/TermsOfUse.vue'
|
||||
|
||||
const store = createStore({
|
||||
state: {
|
||||
loggedIn: false,
|
||||
user: null,
|
||||
registerOpen: false,
|
||||
loginOpen: false,
|
||||
loginOpen: false
|
||||
},
|
||||
mutations: {
|
||||
login (state, loggedIn) {
|
||||
state.loggedIn = loggedIn;
|
||||
state.loggedIn = loggedIn
|
||||
},
|
||||
setUser (state, user) {
|
||||
state.user = user;
|
||||
state.user = user
|
||||
if (user && window.drift && window.drift.identify) {
|
||||
window.drift.identify(user._id, {
|
||||
email: user.email,
|
||||
firstName: user.firstName,
|
||||
});
|
||||
firstName: user.firstName
|
||||
})
|
||||
}
|
||||
if (!user && window.drift && window.drift.reset) {
|
||||
window.drift.reset();
|
||||
window.drift.reset()
|
||||
}
|
||||
},
|
||||
updateProfile (state, profile) {
|
||||
state.user = Object.assign({}, state.user, profile);
|
||||
state.user = Object.assign({}, state.user, profile)
|
||||
},
|
||||
openRegister (state, open) {
|
||||
state.registerOpen = open;
|
||||
state.registerOpen = open
|
||||
},
|
||||
openLogin (state, open) {
|
||||
state.loginOpen = open;
|
||||
},
|
||||
state.loginOpen = open
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const router = createRouter({
|
||||
scrollBehavior() {
|
||||
return { left: 0, top: 0 };
|
||||
scrollBehavior () {
|
||||
return { left: 0, top: 0 }
|
||||
},
|
||||
history: createWebHistory(),
|
||||
routes: [
|
||||
@ -79,24 +79,32 @@ const router = createRouter({
|
||||
{ path: '/account', component: Account },
|
||||
{ path: '/password/reset', component: ResetPassword },
|
||||
{ path: '/dashboard', component: Dashboard },
|
||||
{ path: '/guides', component: GuideLayout, children: [
|
||||
{ path: 'oauth2', component: IDPOAuthGuide },
|
||||
{ path: 'saml2', component: IDPSaml2Guide },
|
||||
] },
|
||||
{
|
||||
path: '/guides',
|
||||
component: GuideLayout,
|
||||
children: [
|
||||
{ path: 'oauth2', component: IDPOAuthGuide },
|
||||
{ path: 'saml2', component: IDPSaml2Guide }
|
||||
]
|
||||
},
|
||||
{ path: '/idps/new', component: NewIDP },
|
||||
{ path: '/idps/:id', component: IDP, children: [
|
||||
{ path: '', component: IDPHome },
|
||||
{ path: 'users', component: IDPUsers },
|
||||
{ path: 'settings', component: IDPSettings },
|
||||
{ path: 'sps', component: IDPSPs },
|
||||
{ path: 'saml', component: IDPSAML },
|
||||
{ path: 'saml/guide', component: IDPSaml2Guide },
|
||||
{ path: 'saml/logs', component: IDPSAMLLogs },
|
||||
{ path: 'oauth', component: IDPOAuth },
|
||||
{ path: 'oauth/guide', component: IDPOAuthGuide },
|
||||
{ path: 'oauth/logs', component: IDPOAuthLogs },
|
||||
] },
|
||||
{ path: '/root', component: Root },
|
||||
{
|
||||
path: '/idps/:id',
|
||||
component: IDP,
|
||||
children: [
|
||||
{ path: '', component: IDPHome },
|
||||
{ path: 'users', component: IDPUsers },
|
||||
{ path: 'settings', component: IDPSettings },
|
||||
{ path: 'sps', component: IDPSPs },
|
||||
{ path: 'saml', component: IDPSAML },
|
||||
{ path: 'saml/guide', component: IDPSaml2Guide },
|
||||
{ path: 'saml/logs', component: IDPSAMLLogs },
|
||||
{ path: 'oauth', component: IDPOAuth },
|
||||
{ path: 'oauth/guide', component: IDPOAuthGuide },
|
||||
{ path: 'oauth/logs', component: IDPOAuthLogs }
|
||||
]
|
||||
},
|
||||
{ path: '/root', component: Root }
|
||||
]
|
||||
})
|
||||
|
||||
@ -107,13 +115,13 @@ const vuetify = createVuetify({
|
||||
defaultSet: 'mdi',
|
||||
aliases,
|
||||
sets: {
|
||||
mdi,
|
||||
mdi
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
const app = createApp(App)
|
||||
app.use(store)
|
||||
app.use(vuetify)
|
||||
app.use(router)
|
||||
app.mount('#app')
|
||||
app.mount('#app')
|
||||
|
@ -1,6 +1,6 @@
|
||||
export default {
|
||||
hasPermission(user, permission, scope) {
|
||||
if (!user?.permissions || !permission) return false;
|
||||
return user.permissions[scope || 'global']?.indexOf(permission) > -1;
|
||||
hasPermission (user, permission, scope) {
|
||||
if (!user?.permissions || !permission) return false
|
||||
return user.permissions[scope || 'global']?.indexOf(permission) > -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,4 +2,4 @@ import vue from '@vitejs/plugin-vue'
|
||||
|
||||
export default {
|
||||
plugins: [vue()]
|
||||
}
|
||||
}
|
||||
|
1901
web/yarn.lock
1901
web/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user