feat: allow api based auth
This commit is contained in:
@@ -9,6 +9,11 @@ import {
|
||||
|
||||
export default {
|
||||
validityCheck() {
|
||||
if (this.hasAuthToken()) {
|
||||
const urlData = endPoints('profileUpdate');
|
||||
return axios.get(urlData.url);
|
||||
}
|
||||
|
||||
const urlData = endPoints('validityCheck');
|
||||
return axios.get(urlData.url);
|
||||
},
|
||||
@@ -31,6 +36,10 @@ export default {
|
||||
hasAuthCookie() {
|
||||
return !!Cookies.get('cw_d_session_info');
|
||||
},
|
||||
hasAuthToken() {
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
return !!window.__WOOT_ACCESS_TOKEN__;
|
||||
},
|
||||
getAuthData() {
|
||||
if (this.hasAuthCookie()) {
|
||||
const savedAuthInfo = Cookies.get('cw_d_session_info');
|
||||
|
||||
@@ -115,7 +115,7 @@ export const actions = {
|
||||
}
|
||||
},
|
||||
async setUser({ commit, dispatch }) {
|
||||
if (authAPI.hasAuthCookie()) {
|
||||
if (authAPI.hasAuthCookie() || authAPI.hasAuthToken()) {
|
||||
await dispatch('validityCheck');
|
||||
} else {
|
||||
commit(types.CLEAR_USER);
|
||||
|
||||
@@ -28,6 +28,7 @@ const i18n = createI18n({
|
||||
|
||||
const ceOptions = {
|
||||
configureApp(app) {
|
||||
store.dispatch('setUser');
|
||||
app.use(store);
|
||||
app.use(i18n);
|
||||
app.use(VueDOMPurifyHTML, domPurifyConfig);
|
||||
|
||||
Reference in New Issue
Block a user