Skip to content

Commit

Permalink
Merge pull request #12 from codedthemes/bugfix
Browse files Browse the repository at this point in the history
login url main routes name change
  • Loading branch information
ct-anjali-rana authored Mar 4, 2024
2 parents 9991d61 + 5070b46 commit ae90be9
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/layouts/full/vertical-sidebar/sidebarItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const sidebarItem: menu[] = [
{
title: 'Login',
icon: CircleIcon,
to: '/auth/login'
to: '/auth/login1'
},
{
title: 'Register',
Expand Down
2 changes: 1 addition & 1 deletion src/router/AuthRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const AuthRoutes = {
children: [
{
name: 'Login',
path: '/auth/login',
path: '/auth/login1',
component: () => import('@/views/authentication/auth/LoginPage.vue')
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/router/MainRoutes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const MainRoutes = {
path: '/main',
meta: {
requiresAuth: false
requiresAuth: true
},
redirect: '/dashboard/default',
redirect: '/main/dashboard/default',
component: () => import('@/layouts/full/FullLayout.vue'),
children: [
{
Expand Down
4 changes: 2 additions & 2 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ interface AuthStore {

router.beforeEach(async (to, from, next) => {
// redirect to login page if not logged in and trying to access a restricted page
const publicPages = ['/auth/login'];
const publicPages = ['/auth/login1'];
const authRequired = !publicPages.includes(to.path);
const auth: AuthStore = useAuthStore();

if (to.matched.some((record) => record.meta.requiresAuth)) {
if (authRequired && !auth.user) {
auth.returnUrl = to.fullPath;
return next('/auth/login');
return next('/auth/login1');
} else next();
} else {
next();
Expand Down
4 changes: 2 additions & 2 deletions src/stores/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ export const useAuthStore = defineStore({
// store user details and jwt in local storage to keep user logged in between page refreshes
localStorage.setItem('user', JSON.stringify(user));
// redirect to previous url or default to home page
router.push(this.returnUrl || '/dashboard/default');
router.push(this.returnUrl || '/');
},
logout() {
this.user = null;
localStorage.removeItem('user');
router.push('/auth/login');
router.push('/auth/login1');
}
}
});
1 change: 1 addition & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'lodash';
2 changes: 1 addition & 1 deletion src/views/authentication/authForms/AuthRegister.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function validate() {
</v-form>
<div class="mt-5 text-right">
<v-divider />
<v-btn variant="plain" to="/auth/login" class="mt-2 text-capitalize mr-n2">Already have an account?</v-btn>
<v-btn variant="plain" to="/auth/login1" class="mt-2 text-capitalize mr-n2">Already have an account?</v-btn>
</div>
</template>
<style lang="scss">
Expand Down

0 comments on commit ae90be9

Please sign in to comment.