Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
K
kiaisoft_tuananh_nuxt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TTS Tran Viet Anh
kiaisoft_tuananh_nuxt
Commits
e8dd1c73
Commit
e8dd1c73
authored
Feb 09, 2023
by
TTS Kieu Tuan Anh
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into 'feature/UI-vuetify'
# Conflicts: # pages/login.vue # plugins/axios.js
parents
fdd32d6c
205c8dde
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
29 deletions
+29
-29
Navbar.vue
components/Navbar.vue
+18
-14
login.vue
pages/login.vue
+8
-13
axios.js
plugins/axios.js
+3
-2
No files found.
components/Navbar.vue
View file @
e8dd1c73
...
...
@@ -81,22 +81,26 @@
<
script
>
export
default
{
methods
:
{
logout
()
{
fetch
(
'
http://127.0.0.1:8000/api/logout
'
,
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
accept
:
'
application/json
'
},
body
:
JSON
.
stringify
({
async
logout
()
{
try
{
const
resp
=
await
this
.
$axios
.
post
(
'
/logout
'
,
{
token
:
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)
})
})
localStorage
.
setItem
(
'
token
'
,
''
)
this
.
$auth
.
$storage
.
setUniversal
(
'
loggedIn
'
,
'
false
'
)
this
.
$auth
.
$storage
.
setUniversal
(
'
token
'
,
''
)
this
.
$auth
.
$storage
.
setUniversal
(
'
userName
'
,
''
)
this
.
$router
.
push
(
'
/login
'
)
if
(
resp
.
status
==
'
200
'
)
{
this
.
$toast
.
success
(
'
Logout!
'
,
{
duration
:
2000
})
this
.
$router
.
push
(
'
/login
'
)
localStorage
.
setItem
(
'
token
'
,
''
)
this
.
$auth
.
$storage
.
setUniversal
(
'
loggedIn
'
,
'
false
'
)
this
.
$auth
.
$storage
.
setUniversal
(
'
token
'
,
''
)
this
.
$auth
.
$storage
.
setUniversal
(
'
userName
'
,
''
)
}
}
catch
(
e
)
{
this
.
$toast
.
error
(
'
ERR !
'
,
{
duration
:
2000
})
}
}
}
}
...
...
pages/login.vue
View file @
e8dd1c73
...
...
@@ -109,15 +109,10 @@ export default {
this
.
password
=
''
this
.
checkbox
=
false
},
async
login
()
{
async
login
()
{
try
{
const
resp
=
await
fetch
(
'
http://127.0.0.1:8000/api/login
'
,
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Accept
:
'
application/json
'
},
body
:
JSON
.
stringify
({
const
resp
=
await
this
.
$axios
.
post
(
'
/login
'
,
{
email
:
this
.
email
,
password
:
this
.
password
,
status
:
this
.
status
...
...
@@ -137,13 +132,13 @@ export default {
this
.
$router
.
push
(
'
home
'
)
}
}
catch
(
e
)
{
this
.
$toast
.
error
(
'
Username or Password not valid
'
,
{
duration
:
2000
})
this
.
$router
.
push
(
'
/login
'
)
this
.
$toast
.
error
(
"
Username or Password not valid
"
,
{
duration
:
2000
,
})
;
this
.
$router
.
push
(
"
/login
"
);
}
}
}
}
}
</
script
>
<
style
scoped
>
...
...
plugins/axios.js
View file @
e8dd1c73
export
default
function
({
$axios
},
inject
,
redirect
)
{
export
default
function
({
$axios
},
inject
,
redirect
)
{
$axios
.
onError
((
error
)
=>
{
if
(
error
.
response
.
status
===
500
)
{
redirect
(
'
/500
'
)
...
...
@@ -15,7 +15,8 @@ export default function ({ $axios }, inject, redirect ) {
const
api
=
$axios
.
create
({
headers
:
{
common
:
{
Accept
:
'
application/json, text/plain, */*
'
Accept
:
'
application/json, text/plain, */*
'
,
'
Content-Type
'
:
'
application/json, text/plain, */*
'
}
}
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment