Skip to content

Commit 42f8932

Browse files
dxvladislavvolkovdxvladislavvolkov
authored andcommitted
Revert "Implement auth"
This reverts commit c3f74f2.
1 parent c3f74f2 commit 42f8932

File tree

10 files changed

+96
-654
lines changed

10 files changed

+96
-654
lines changed

src/auth.js

Lines changed: 7 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,12 @@
1-
const defaultPath = '/';
2-
const defaultUser = {
3-
email: 'sandra@example.com',
4-
avatarUrl: 'https://js.devexpress.com/Demos/WidgetsGallery/JSDemos/images/employees/06.png'
5-
};
6-
1+
let authenticated = true;
72
export default {
8-
_user: defaultUser,
9-
loggedIn() {
10-
return !!this._user;
11-
},
12-
_lastAuthenticatedPath: defaultPath,
13-
lastAuthenticatedPath(value) {
14-
this._lastAuthenticatedPath = value;
15-
},
16-
17-
async logIn(email, password) {
18-
try {
19-
// Send request
20-
console.log(email, password);
21-
this._user = { ...defaultUser, email };
22-
23-
return {
24-
isOk: true,
25-
data: this._user
26-
};
27-
}
28-
catch {
29-
return {
30-
isOk: false,
31-
message: "Authentication failed"
32-
};
33-
}
34-
},
35-
36-
async logOut() {
37-
this._user = null;
38-
},
39-
40-
async getUser() {
41-
try {
42-
// Send request
43-
44-
return {
45-
isOk: true,
46-
data: this._user
47-
};
48-
}
49-
catch {
50-
return {
51-
isOk: false
52-
};
53-
}
54-
},
55-
56-
async resetPassword(email) {
57-
try {
58-
// Send request
59-
console.log(email);
60-
61-
return {
62-
isOk: true
63-
};
64-
}
65-
catch {
66-
return {
67-
isOk: false,
68-
message: "Failed to reset password"
69-
};
70-
}
3+
authenticated() {
4+
return authenticated;
715
},
72-
73-
async changePassword(email, recoveryCode) {
74-
try {
75-
// Send request
76-
console.log(email, recoveryCode);
77-
78-
return {
79-
isOk: true
80-
};
81-
}
82-
catch {
83-
return {
84-
isOk: false,
85-
message: "Failed to change password"
86-
}
87-
}
6+
logIn() {
7+
authenticated = true;
888
},
89-
90-
async createAccount(email, password) {
91-
try {
92-
// Send request
93-
console.log(email, password);
94-
95-
return {
96-
isOk: true
97-
};
98-
}
99-
catch {
100-
return {
101-
isOk: false,
102-
message: "Failed to create account"
103-
};
104-
}
9+
logOut() {
10+
authenticated = false;
10511
}
10612
};

src/components/header-toolbar.vue

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@
4040
height="100%"
4141
styling-mode="text"
4242
>
43-
<user-panel :user="user" :menu-items="userMenuItems" menu-mode="context" />
43+
<user-panel :menu-items="userMenuItems" menu-mode="context" />
4444
</dx-button>
4545
</div>
4646
</dx-item>
4747
<!-- eslint-disable vue/no-unused-vars -->
4848
<user-panel
49-
:user="user"
5049
:menu-items="userMenuItems"
5150
menu-mode="list"
5251
slot-scope="_"
@@ -69,15 +68,10 @@ export default {
6968
menuToggleEnabled: Boolean,
7069
title: String,
7170
toggleMenuFunc: Function,
72-
logOutFunc: Function,
73-
},
74-
/* eslint-disable no-debugger */
75-
created() {
76-
auth.getUser().then((e) => this.user = e.data);
71+
logOutFunc: Function
7772
},
7873
data() {
7974
return {
80-
user: { },
8175
userMenuItems: [
8276
{
8377
text: "Profile",

src/components/user-panel.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="image-container">
55
<div class="user-image" />
66
</div>
7-
<div class="user-name">{{user.email}}</div>
7+
<div class="user-name">sandra@example.com</div>
88
</div>
99

1010
<dx-context-menu
@@ -33,8 +33,7 @@ import DxList from "devextreme-vue/list";
3333
export default {
3434
props: {
3535
menuMode: String,
36-
menuItems: Array,
37-
user: Object
36+
menuItems: Array
3837
},
3938
components: {
4039
DxContextMenu,

src/layouts/single-card.vue

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
<template>
22
<dx-scroll-view height="100%" width="100%" class="with-footer single-card">
3-
<div class="dx-card content">
4-
<div class="header">
5-
<div class="title">{{title}}</div>
6-
<div class="description">{{description}}</div>
7-
</div>
8-
<slot />
9-
</div>
3+
<div class="dx-card"><slot /></div>
104
</dx-scroll-view>
115
</template>
126

@@ -16,26 +10,17 @@ import DxScrollView from "devextreme-vue/scroll-view";
1610
export default {
1711
components: {
1812
DxScrollView
19-
},
20-
props: {
21-
title: String,
22-
description: String
2313
}
2414
};
2515
</script>
2616

2717
<style lang="scss">
28-
@import "../themes/generated/variables.base.scss";
29-
3018
.single-card {
31-
width: 100%;
32-
height: 100%;
3319
3420
.dx-card {
3521
width: 330px;
3622
margin: auto auto;
3723
padding: 40px;
38-
flex-grow: 0;
3924
4025
.screen-x-small & {
4126
width: 100%;
@@ -46,22 +31,6 @@ export default {
4631
border: 0;
4732
flex-grow: 1;
4833
}
49-
50-
.header {
51-
margin-bottom: 30px;
52-
53-
.title {
54-
color: $base-text-color;
55-
line-height: 28px;
56-
font-weight: 500;
57-
font-size: 24px;
58-
}
59-
60-
.description {
61-
color: rgba($base-text-color, alpha($base-text-color) * 0.7);
62-
line-height: 18px;
63-
}
64-
}
6534
}
6635
}
6736

src/router.js

Lines changed: 5 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -46,59 +46,11 @@ const router = new Router({
4646
meta: { requiresAuth: false },
4747
components: {
4848
layout: simpleLayout,
49+
// route level code-splitting
50+
// this generates a separate chunk (login.[hash].js) for this route
51+
// which is lazy-loaded when the route is visited.
4952
content: () =>
5053
import(/* webpackChunkName: "login" */ "./views/login-form")
51-
},
52-
props: {
53-
layout: {
54-
title: "Sign In"
55-
}
56-
}
57-
},
58-
{
59-
path: "/reset-password",
60-
name: "reset-password",
61-
meta: { requiresAuth: false },
62-
components: {
63-
layout: simpleLayout,
64-
content: () =>
65-
import(/* webpackChunkName: "login" */ "./views/reset-password-form")
66-
},
67-
props: {
68-
layout: {
69-
title: "Reset Password",
70-
description: "Please enter the email address that you used to register, and we will send you a link to reset your password via Email."
71-
}
72-
}
73-
},
74-
{
75-
path: "/create-account",
76-
name: "create-account",
77-
meta: { requiresAuth: false },
78-
components: {
79-
layout: simpleLayout,
80-
content: () =>
81-
import(/* webpackChunkName: "login" */ "./views/create-account-form")
82-
},
83-
props: {
84-
layout: {
85-
title: "Sign Up"
86-
}
87-
}
88-
},
89-
{
90-
path: "/change-password/:recoveryCode",
91-
name: "change-password",
92-
meta: { requiresAuth: false },
93-
components: {
94-
layout: simpleLayout,
95-
content: () =>
96-
import(/* webpackChunkName: "login" */ "./views/change-password-form")
97-
},
98-
props: {
99-
layout: {
100-
title: "Change Password"
101-
}
10254
}
10355
},
10456
{
@@ -118,12 +70,12 @@ const router = new Router({
11870

11971
router.beforeEach((to, from, next) => {
12072

121-
if (to.name === "login-form" && auth.loggedIn()) {
73+
if (to.name === "login-form" && auth.authenticated()) {
12274
next({ name: "home" });
12375
}
12476

12577
if (to.matched.some(record => record.meta.requiresAuth)) {
126-
if (!auth.loggedIn()) {
78+
if (!auth.authenticated()) {
12779
next({
12880
name: "login-form",
12981
query: { redirect: to.fullPath }

0 commit comments

Comments
 (0)