feat: allow api based auth

This commit is contained in:
Shivam Mishra
2025-05-12 17:35:06 +05:30
parent 4ecc92ad6d
commit a97cf6e4ad
3 changed files with 11 additions and 1 deletions
+9
View File
@@ -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);
+1
View File
@@ -28,6 +28,7 @@ const i18n = createI18n({
const ceOptions = {
configureApp(app) {
store.dispatch('setUser');
app.use(store);
app.use(i18n);
app.use(VueDOMPurifyHTML, domPurifyConfig);